18#ifndef INCLUDE_NLOHMANN_JSON_HPP_
19#define INCLUDE_NLOHMANN_JSON_HPP_
24#include <initializer_list>
60#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
61#if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
62#if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 2
63#warning "Already included a different version of the library!"
68#define NLOHMANN_JSON_VERSION_MAJOR 3
69#define NLOHMANN_JSON_VERSION_MINOR 11
70#define NLOHMANN_JSON_VERSION_PATCH 2
72#ifndef JSON_DIAGNOSTICS
73#define JSON_DIAGNOSTICS 0
76#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
77#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
81#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
83#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
86#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
87#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
89#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
92#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
93#define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
97#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
98#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
99 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
101#define NLOHMANN_JSON_ABI_TAGS \
102 NLOHMANN_JSON_ABI_TAGS_CONCAT( \
103 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
104 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
107#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
108 _v ## major ## _ ## minor ## _ ## patch
109#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
110 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
112#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
113#define NLOHMANN_JSON_NAMESPACE_VERSION
115#define NLOHMANN_JSON_NAMESPACE_VERSION \
116 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
117 NLOHMANN_JSON_VERSION_MINOR, \
118 NLOHMANN_JSON_VERSION_PATCH)
122#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
123#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
124 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
126#ifndef NLOHMANN_JSON_NAMESPACE
127#define NLOHMANN_JSON_NAMESPACE \
128 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
129 NLOHMANN_JSON_ABI_TAGS, \
130 NLOHMANN_JSON_NAMESPACE_VERSION)
133#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
134#define NLOHMANN_JSON_NAMESPACE_BEGIN \
137 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
138 NLOHMANN_JSON_ABI_TAGS, \
139 NLOHMANN_JSON_NAMESPACE_VERSION) \
143#ifndef NLOHMANN_JSON_NAMESPACE_END
144#define NLOHMANN_JSON_NAMESPACE_END \
162#include <forward_list>
167#include <type_traits>
168#include <unordered_map>
231#include <type_traits>
276 template<
class Default,
278 template<
class...>
class Op,
286 template<
class Default,
template<
class...>
class Op,
class... Args>
293 template<
template<
class...>
class Op,
class... Args>
296 template<
template<
class...>
class Op,
class... Args>
299 template<
template<
class...>
class Op,
class... Args>
302 template<
class Default,
template<
class...>
class Op,
class... Args>
305 template<
class Default,
template<
class...>
class Op,
class... Args>
308 template<
class Expected,
template<
class...>
class Op,
class... Args>
311 template<
class To,
template<
class...>
class Op,
class... Args>
313 std::is_convertible<
detected_t<Op, Args...>, To>;
334#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
335#if defined(JSON_HEDLEY_VERSION)
336#undef JSON_HEDLEY_VERSION
338#define JSON_HEDLEY_VERSION 15
340#if defined(JSON_HEDLEY_STRINGIFY_EX)
341#undef JSON_HEDLEY_STRINGIFY_EX
343#define JSON_HEDLEY_STRINGIFY_EX(x) #x
345#if defined(JSON_HEDLEY_STRINGIFY)
346#undef JSON_HEDLEY_STRINGIFY
348#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
350#if defined(JSON_HEDLEY_CONCAT_EX)
351#undef JSON_HEDLEY_CONCAT_EX
353#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
355#if defined(JSON_HEDLEY_CONCAT)
356#undef JSON_HEDLEY_CONCAT
358#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
360#if defined(JSON_HEDLEY_CONCAT3_EX)
361#undef JSON_HEDLEY_CONCAT3_EX
363#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
365#if defined(JSON_HEDLEY_CONCAT3)
366#undef JSON_HEDLEY_CONCAT3
368#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
370#if defined(JSON_HEDLEY_VERSION_ENCODE)
371#undef JSON_HEDLEY_VERSION_ENCODE
373#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
375#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
376#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
378#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
380#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
381#undef JSON_HEDLEY_VERSION_DECODE_MINOR
383#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
385#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
386#undef JSON_HEDLEY_VERSION_DECODE_REVISION
388#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
390#if defined(JSON_HEDLEY_GNUC_VERSION)
391#undef JSON_HEDLEY_GNUC_VERSION
393#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
394#define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
395#elif defined(__GNUC__)
396#define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
399#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
400#undef JSON_HEDLEY_GNUC_VERSION_CHECK
402#if defined(JSON_HEDLEY_GNUC_VERSION)
403#define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
405#define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
408#if defined(JSON_HEDLEY_MSVC_VERSION)
409#undef JSON_HEDLEY_MSVC_VERSION
411#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
412#define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
413#elif defined(_MSC_FULL_VER) && !defined(__ICL)
414#define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
415#elif defined(_MSC_VER) && !defined(__ICL)
416#define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
419#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
420#undef JSON_HEDLEY_MSVC_VERSION_CHECK
422#if !defined(JSON_HEDLEY_MSVC_VERSION)
423#define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
424#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
425#define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
426#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
427#define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
429#define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
432#if defined(JSON_HEDLEY_INTEL_VERSION)
433#undef JSON_HEDLEY_INTEL_VERSION
435#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
436#define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
437#elif defined(__INTEL_COMPILER) && !defined(__ICL)
438#define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
441#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
442#undef JSON_HEDLEY_INTEL_VERSION_CHECK
444#if defined(JSON_HEDLEY_INTEL_VERSION)
445#define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
447#define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
450#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
451#undef JSON_HEDLEY_INTEL_CL_VERSION
453#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
454#define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
457#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
458#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
460#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
461#define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
463#define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
466#if defined(JSON_HEDLEY_PGI_VERSION)
467#undef JSON_HEDLEY_PGI_VERSION
469#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
470#define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
473#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
474#undef JSON_HEDLEY_PGI_VERSION_CHECK
476#if defined(JSON_HEDLEY_PGI_VERSION)
477#define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
479#define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
482#if defined(JSON_HEDLEY_SUNPRO_VERSION)
483#undef JSON_HEDLEY_SUNPRO_VERSION
485#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
486#define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
487#elif defined(__SUNPRO_C)
488#define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
489#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
490#define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
491#elif defined(__SUNPRO_CC)
492#define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
495#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
496#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
498#if defined(JSON_HEDLEY_SUNPRO_VERSION)
499#define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
501#define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
504#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
505#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
507#if defined(__EMSCRIPTEN__)
508#define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
511#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
512#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
514#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
515#define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
517#define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
520#if defined(JSON_HEDLEY_ARM_VERSION)
521#undef JSON_HEDLEY_ARM_VERSION
523#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
524#define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
525#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
526#define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
529#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
530#undef JSON_HEDLEY_ARM_VERSION_CHECK
532#if defined(JSON_HEDLEY_ARM_VERSION)
533#define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
535#define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
538#if defined(JSON_HEDLEY_IBM_VERSION)
539#undef JSON_HEDLEY_IBM_VERSION
541#if defined(__ibmxl__)
542#define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
543#elif defined(__xlC__) && defined(__xlC_ver__)
544#define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
545#elif defined(__xlC__)
546#define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
549#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
550#undef JSON_HEDLEY_IBM_VERSION_CHECK
552#if defined(JSON_HEDLEY_IBM_VERSION)
553#define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
555#define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
558#if defined(JSON_HEDLEY_TI_VERSION)
559#undef JSON_HEDLEY_TI_VERSION
562 defined(__TI_COMPILER_VERSION__) && \
564 defined(__TMS470__) || defined(__TI_ARM__) || \
565 defined(__MSP430__) || \
566 defined(__TMS320C2000__) \
568#if (__TI_COMPILER_VERSION__ >= 16000000)
569#define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
573#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
574#undef JSON_HEDLEY_TI_VERSION_CHECK
576#if defined(JSON_HEDLEY_TI_VERSION)
577#define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
579#define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
582#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
583#undef JSON_HEDLEY_TI_CL2000_VERSION
585#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
586#define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
589#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
590#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
592#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
593#define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
595#define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
598#if defined(JSON_HEDLEY_TI_CL430_VERSION)
599#undef JSON_HEDLEY_TI_CL430_VERSION
601#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
602#define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
605#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
606#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
608#if defined(JSON_HEDLEY_TI_CL430_VERSION)
609#define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
611#define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
614#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
615#undef JSON_HEDLEY_TI_ARMCL_VERSION
617#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
618#define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
621#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
622#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
624#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
625#define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
627#define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
630#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
631#undef JSON_HEDLEY_TI_CL6X_VERSION
633#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
634#define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
637#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
638#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
640#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
641#define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
643#define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
646#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
647#undef JSON_HEDLEY_TI_CL7X_VERSION
649#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
650#define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
653#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
654#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
656#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
657#define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
659#define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
662#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
663#undef JSON_HEDLEY_TI_CLPRU_VERSION
665#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
666#define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
669#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
670#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
672#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
673#define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
675#define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
678#if defined(JSON_HEDLEY_CRAY_VERSION)
679#undef JSON_HEDLEY_CRAY_VERSION
682#if defined(_RELEASE_PATCHLEVEL)
683#define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
685#define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
689#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
690#undef JSON_HEDLEY_CRAY_VERSION_CHECK
692#if defined(JSON_HEDLEY_CRAY_VERSION)
693#define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
695#define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
698#if defined(JSON_HEDLEY_IAR_VERSION)
699#undef JSON_HEDLEY_IAR_VERSION
701#if defined(__IAR_SYSTEMS_ICC__)
703#define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
705#define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
709#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
710#undef JSON_HEDLEY_IAR_VERSION_CHECK
712#if defined(JSON_HEDLEY_IAR_VERSION)
713#define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
715#define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
718#if defined(JSON_HEDLEY_TINYC_VERSION)
719#undef JSON_HEDLEY_TINYC_VERSION
721#if defined(__TINYC__)
722#define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
725#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
726#undef JSON_HEDLEY_TINYC_VERSION_CHECK
728#if defined(JSON_HEDLEY_TINYC_VERSION)
729#define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
731#define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
734#if defined(JSON_HEDLEY_DMC_VERSION)
735#undef JSON_HEDLEY_DMC_VERSION
738#define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
741#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
742#undef JSON_HEDLEY_DMC_VERSION_CHECK
744#if defined(JSON_HEDLEY_DMC_VERSION)
745#define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
747#define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
750#if defined(JSON_HEDLEY_COMPCERT_VERSION)
751#undef JSON_HEDLEY_COMPCERT_VERSION
753#if defined(__COMPCERT_VERSION__)
754#define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
757#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
758#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
760#if defined(JSON_HEDLEY_COMPCERT_VERSION)
761#define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
763#define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
766#if defined(JSON_HEDLEY_PELLES_VERSION)
767#undef JSON_HEDLEY_PELLES_VERSION
770#define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
773#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
774#undef JSON_HEDLEY_PELLES_VERSION_CHECK
776#if defined(JSON_HEDLEY_PELLES_VERSION)
777#define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
779#define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
782#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
783#undef JSON_HEDLEY_MCST_LCC_VERSION
785#if defined(__LCC__) && defined(__LCC_MINOR__)
786#define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
789#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
790#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
792#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
793#define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
795#define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
798#if defined(JSON_HEDLEY_GCC_VERSION)
799#undef JSON_HEDLEY_GCC_VERSION
802 defined(JSON_HEDLEY_GNUC_VERSION) && \
803 !defined(__clang__) && \
804 !defined(JSON_HEDLEY_INTEL_VERSION) && \
805 !defined(JSON_HEDLEY_PGI_VERSION) && \
806 !defined(JSON_HEDLEY_ARM_VERSION) && \
807 !defined(JSON_HEDLEY_CRAY_VERSION) && \
808 !defined(JSON_HEDLEY_TI_VERSION) && \
809 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
810 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
811 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
812 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
813 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
814 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
815 !defined(__COMPCERT__) && \
816 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
817#define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
820#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
821#undef JSON_HEDLEY_GCC_VERSION_CHECK
823#if defined(JSON_HEDLEY_GCC_VERSION)
824#define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
826#define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
829#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
830#undef JSON_HEDLEY_HAS_ATTRIBUTE
833 defined(__has_attribute) && \
835 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
837# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
839# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
842#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
843#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
845#if defined(__has_attribute)
846#define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
848#define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
851#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
852#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
854#if defined(__has_attribute)
855#define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
857#define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
860#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
861#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
864 defined(__has_cpp_attribute) && \
865 defined(__cplusplus) && \
866 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
867#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
869#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
872#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
873#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
875#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
876#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
878 !defined(JSON_HEDLEY_PGI_VERSION) && \
879 !defined(JSON_HEDLEY_IAR_VERSION) && \
880 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
881 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
882#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
884#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
887#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
888#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
890#if defined(__has_cpp_attribute) && defined(__cplusplus)
891#define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
893#define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
896#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
897#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
899#if defined(__has_cpp_attribute) && defined(__cplusplus)
900#define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
902#define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
905#if defined(JSON_HEDLEY_HAS_BUILTIN)
906#undef JSON_HEDLEY_HAS_BUILTIN
908#if defined(__has_builtin)
909#define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
911#define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
914#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
915#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
917#if defined(__has_builtin)
918#define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
920#define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
923#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
924#undef JSON_HEDLEY_GCC_HAS_BUILTIN
926#if defined(__has_builtin)
927#define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
929#define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
932#if defined(JSON_HEDLEY_HAS_FEATURE)
933#undef JSON_HEDLEY_HAS_FEATURE
935#if defined(__has_feature)
936#define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
938#define JSON_HEDLEY_HAS_FEATURE(feature) (0)
941#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
942#undef JSON_HEDLEY_GNUC_HAS_FEATURE
944#if defined(__has_feature)
945#define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
947#define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
950#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
951#undef JSON_HEDLEY_GCC_HAS_FEATURE
953#if defined(__has_feature)
954#define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
956#define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
959#if defined(JSON_HEDLEY_HAS_EXTENSION)
960#undef JSON_HEDLEY_HAS_EXTENSION
962#if defined(__has_extension)
963#define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
965#define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
968#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
969#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
971#if defined(__has_extension)
972#define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
974#define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
977#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
978#undef JSON_HEDLEY_GCC_HAS_EXTENSION
980#if defined(__has_extension)
981#define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
983#define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
986#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
987#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
989#if defined(__has_declspec_attribute)
990#define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
992#define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
995#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
996#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
998#if defined(__has_declspec_attribute)
999#define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1001#define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1004#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1005#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1007#if defined(__has_declspec_attribute)
1008#define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1010#define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1013#if defined(JSON_HEDLEY_HAS_WARNING)
1014#undef JSON_HEDLEY_HAS_WARNING
1016#if defined(__has_warning)
1017#define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1019#define JSON_HEDLEY_HAS_WARNING(warning) (0)
1022#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1023#undef JSON_HEDLEY_GNUC_HAS_WARNING
1025#if defined(__has_warning)
1026#define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1028#define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1031#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1032#undef JSON_HEDLEY_GCC_HAS_WARNING
1034#if defined(__has_warning)
1035#define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1037#define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1041 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1042 defined(__clang__) || \
1043 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1044 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1045 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1046 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1047 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1048 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1049 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1050 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1051 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1052 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1053 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1054 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1055 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1056 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1057 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1058 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1059#define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1060#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1061#define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1063#define JSON_HEDLEY_PRAGMA(value)
1066#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1067#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1069#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1070#undef JSON_HEDLEY_DIAGNOSTIC_POP
1072#if defined(__clang__)
1073#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1074#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1075#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1076#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1077#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1078#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1079#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1080#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1082 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1083 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1084#define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1085#define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1086#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1087#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1088#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1090 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1091 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1092 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1093 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1094 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1095 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1096#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1097#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1098#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1099#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1100#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1102#define JSON_HEDLEY_DIAGNOSTIC_PUSH
1103#define JSON_HEDLEY_DIAGNOSTIC_POP
1108#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1109#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1111#if defined(__cplusplus)
1112# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1113# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1114# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1115# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1116 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1117 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1118 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1119 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1121 JSON_HEDLEY_DIAGNOSTIC_POP
1123# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1124 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1125 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1126 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1128 JSON_HEDLEY_DIAGNOSTIC_POP
1131# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1132 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1133 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1135 JSON_HEDLEY_DIAGNOSTIC_POP
1139#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1140#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1143#if defined(JSON_HEDLEY_CONST_CAST)
1144#undef JSON_HEDLEY_CONST_CAST
1146#if defined(__cplusplus)
1147# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1149 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1150 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1151 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1152# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1153 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1154 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1156 JSON_HEDLEY_DIAGNOSTIC_POP \
1159# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1162#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1163#undef JSON_HEDLEY_REINTERPRET_CAST
1165#if defined(__cplusplus)
1166#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1168#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1171#if defined(JSON_HEDLEY_STATIC_CAST)
1172#undef JSON_HEDLEY_STATIC_CAST
1174#if defined(__cplusplus)
1175#define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1177#define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1180#if defined(JSON_HEDLEY_CPP_CAST)
1181#undef JSON_HEDLEY_CPP_CAST
1183#if defined(__cplusplus)
1184# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1185# define JSON_HEDLEY_CPP_CAST(T, expr) \
1186 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1187 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1189 JSON_HEDLEY_DIAGNOSTIC_POP
1190# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1191# define JSON_HEDLEY_CPP_CAST(T, expr) \
1192 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1193 _Pragma("diag_suppress=Pe137") \
1194 JSON_HEDLEY_DIAGNOSTIC_POP
1196# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1199# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1202#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1203#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1205#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1206#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1207#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1208#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1209#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1210#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1211#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1212#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1213#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1214#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1215#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1216#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1217#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1218#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1219#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1220#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1222 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1223 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1224 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1225 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1226 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1227 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1228 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1229 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1230 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1231 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1232 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1233#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1234#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1235#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1236#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1237#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1238#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1239#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1240#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1241#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1243#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1246#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1247#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1249#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1250#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1251#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1252#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1253#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1254#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1255#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1256#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1257#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1258#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1259#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1260#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1262 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1263 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1264 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1265 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1266#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1267#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1268#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1269#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1270#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1271#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1272#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1274#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1277#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1278#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1280#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1281#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1282#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1283#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1284#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1285#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1286#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1287#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1288#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1289#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1290#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1291#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1292#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1293#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1294#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1295#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1297 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1298 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1299 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1300#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1301#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1302#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1303#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1304#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1306#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1309#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1310#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1312#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1313#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1314#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1315#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1316#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1317#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1319#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1322#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1323#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1325#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1326#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1327#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1328#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1329#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1330#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1331#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1332#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1334#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1337#if defined(JSON_HEDLEY_DEPRECATED)
1338#undef JSON_HEDLEY_DEPRECATED
1340#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1341#undef JSON_HEDLEY_DEPRECATED_FOR
1344 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1345 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1346#define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1347#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1349 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1350 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1351 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1352 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1353 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1354 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1355 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1356 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1357 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1358 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1359 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1360 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1361#define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1362#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1363#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1364#define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1365#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1367 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1368 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1369 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1370 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1371 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1372 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1373 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1374 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1375 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1376 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1377 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1378 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1379 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1380 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1381 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1382 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1383#define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1384#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1386 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1387 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1388 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1389#define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1390#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1391#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1392#define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1393#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1395#define JSON_HEDLEY_DEPRECATED(since)
1396#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1399#if defined(JSON_HEDLEY_UNAVAILABLE)
1400#undef JSON_HEDLEY_UNAVAILABLE
1403 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1404 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1405 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1406 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1407#define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1409#define JSON_HEDLEY_UNAVAILABLE(available_since)
1412#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1413#undef JSON_HEDLEY_WARN_UNUSED_RESULT
1415#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1416#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1419 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1420 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1421 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1422 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1423 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1424 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1425 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1426 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1427 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1428 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1429 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1430 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1431 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1432 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1433 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1434 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1435 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1436#define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1437#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1438#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1439#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1440#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1441#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1442#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1443#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1444#elif defined(_Check_return_)
1445#define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1446#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1448#define JSON_HEDLEY_WARN_UNUSED_RESULT
1449#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1452#if defined(JSON_HEDLEY_SENTINEL)
1453#undef JSON_HEDLEY_SENTINEL
1456 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1457 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1458 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1459 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1460 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1461#define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1463#define JSON_HEDLEY_SENTINEL(position)
1466#if defined(JSON_HEDLEY_NO_RETURN)
1467#undef JSON_HEDLEY_NO_RETURN
1469#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1470#define JSON_HEDLEY_NO_RETURN __noreturn
1472 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1473 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1474#define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1475#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1476#define JSON_HEDLEY_NO_RETURN _Noreturn
1477#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1478#define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1480 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1481 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1482 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1483 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1484 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1485 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1486 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1487 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1488 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1489 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1490 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1491 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1492 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1493 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1494 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1495 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1496 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1497#define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1498#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1499#define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1501 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1502 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1503#define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1504#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1505#define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1506#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1507#define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1508#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1509#define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1511#define JSON_HEDLEY_NO_RETURN
1514#if defined(JSON_HEDLEY_NO_ESCAPE)
1515#undef JSON_HEDLEY_NO_ESCAPE
1517#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1518#define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1520#define JSON_HEDLEY_NO_ESCAPE
1523#if defined(JSON_HEDLEY_UNREACHABLE)
1524#undef JSON_HEDLEY_UNREACHABLE
1526#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1527#undef JSON_HEDLEY_UNREACHABLE_RETURN
1529#if defined(JSON_HEDLEY_ASSUME)
1530#undef JSON_HEDLEY_ASSUME
1533 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1534 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1535 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1536#define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1537#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1538#define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1540 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1541 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1542#if defined(__cplusplus)
1543#define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1545#define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1549 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1550 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1551 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1552 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1553 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1554 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1555 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1556#define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1557#elif defined(JSON_HEDLEY_ASSUME)
1558#define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1560#if !defined(JSON_HEDLEY_ASSUME)
1561#if defined(JSON_HEDLEY_UNREACHABLE)
1562#define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1564#define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1567#if defined(JSON_HEDLEY_UNREACHABLE)
1569 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1570 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1571#define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1573#define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1576#define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1578#if !defined(JSON_HEDLEY_UNREACHABLE)
1579#define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1583#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1584#pragma clang diagnostic ignored "-Wpedantic"
1586#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1587#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1589#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1590#if defined(__clang__)
1591#pragma clang diagnostic ignored "-Wvariadic-macros"
1592#elif defined(JSON_HEDLEY_GCC_VERSION)
1593#pragma GCC diagnostic ignored "-Wvariadic-macros"
1596#if defined(JSON_HEDLEY_NON_NULL)
1597#undef JSON_HEDLEY_NON_NULL
1600 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1601 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1602 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1603 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1604#define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1606#define JSON_HEDLEY_NON_NULL(...)
1610#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1611#undef JSON_HEDLEY_PRINTF_FORMAT
1613#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1614#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1615#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1616#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1618 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1619 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1620 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1621 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1622 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1623 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1624 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1625 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1626 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1627 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1628 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1629 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1630 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1631 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1632 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1633 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1634 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1635#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1636#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1637#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1639#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1642#if defined(JSON_HEDLEY_CONSTEXPR)
1643#undef JSON_HEDLEY_CONSTEXPR
1645#if defined(__cplusplus)
1646#if __cplusplus >= 201103L
1647#define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1650#if !defined(JSON_HEDLEY_CONSTEXPR)
1651#define JSON_HEDLEY_CONSTEXPR
1654#if defined(JSON_HEDLEY_PREDICT)
1655#undef JSON_HEDLEY_PREDICT
1657#if defined(JSON_HEDLEY_LIKELY)
1658#undef JSON_HEDLEY_LIKELY
1660#if defined(JSON_HEDLEY_UNLIKELY)
1661#undef JSON_HEDLEY_UNLIKELY
1663#if defined(JSON_HEDLEY_UNPREDICTABLE)
1664#undef JSON_HEDLEY_UNPREDICTABLE
1666#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1667#define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1670 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1671 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1672 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1673# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1674# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1675# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1676# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1677# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1679 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1680 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1681 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1682 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1683 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1684 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1685 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1686 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1687 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1688 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1689 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1690 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1691 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1692 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1693 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1694 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1695# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1696 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1697# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1699 double hedley_probability_ = (probability); \
1700 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1702# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1704 double hedley_probability_ = (probability); \
1705 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1707# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1708# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1710# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1711# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1712# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1713# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1714# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1716#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1717#define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1720#if defined(JSON_HEDLEY_MALLOC)
1721#undef JSON_HEDLEY_MALLOC
1724 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1725 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1726 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1727 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1728 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1729 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1730 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1731 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1732 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1733 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1734 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1735 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1736 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1737 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1738 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1739 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1740 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1741 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1742#define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1743#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1744#define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1746 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1747 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1748#define JSON_HEDLEY_MALLOC __declspec(restrict)
1750#define JSON_HEDLEY_MALLOC
1753#if defined(JSON_HEDLEY_PURE)
1754#undef JSON_HEDLEY_PURE
1757 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1758 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1759 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1760 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1761 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1762 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1763 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1764 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1765 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1766 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1767 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1768 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1769 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1770 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1771 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1772 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1773 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1774 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1775 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1776# define JSON_HEDLEY_PURE __attribute__((__pure__))
1777#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1778# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1779#elif defined(__cplusplus) && \
1781 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1782 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1783 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1785# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1787# define JSON_HEDLEY_PURE
1790#if defined(JSON_HEDLEY_CONST)
1791#undef JSON_HEDLEY_CONST
1794 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1795 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1796 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1797 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1798 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1799 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1800 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1801 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1802 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1803 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1804 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1805 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1806 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1807 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1808 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1809 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1810 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1811 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1812 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1813#define JSON_HEDLEY_CONST __attribute__((__const__))
1815 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1816#define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1818#define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1821#if defined(JSON_HEDLEY_RESTRICT)
1822#undef JSON_HEDLEY_RESTRICT
1824#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1825#define JSON_HEDLEY_RESTRICT restrict
1827 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1828 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1829 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1830 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1831 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1832 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1833 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1834 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1835 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1836 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1837 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1838 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1839 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1840 defined(__clang__) || \
1841 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1842#define JSON_HEDLEY_RESTRICT __restrict
1843#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1844#define JSON_HEDLEY_RESTRICT _Restrict
1846#define JSON_HEDLEY_RESTRICT
1849#if defined(JSON_HEDLEY_INLINE)
1850#undef JSON_HEDLEY_INLINE
1853 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1854 (defined(__cplusplus) && (__cplusplus >= 199711L))
1855#define JSON_HEDLEY_INLINE inline
1857 defined(JSON_HEDLEY_GCC_VERSION) || \
1858 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1859#define JSON_HEDLEY_INLINE __inline__
1861 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1862 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1863 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1864 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1865 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1866 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1867 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1868 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1869 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1870 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1871#define JSON_HEDLEY_INLINE __inline
1873#define JSON_HEDLEY_INLINE
1876#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1877#undef JSON_HEDLEY_ALWAYS_INLINE
1880 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1881 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1882 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1883 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1884 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1885 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1886 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1887 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1888 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1889 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1890 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1891 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1892 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1893 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1894 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1895 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1896 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1897 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1898 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1899# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1901 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1902 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1903# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1904#elif defined(__cplusplus) && \
1906 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1907 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1908 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1909 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1910 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1911 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1913# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1914#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1915# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1917# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1920#if defined(JSON_HEDLEY_NEVER_INLINE)
1921#undef JSON_HEDLEY_NEVER_INLINE
1924 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1925 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1926 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1927 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1928 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1929 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1930 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1931 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1932 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1933 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1934 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1935 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1936 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1937 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1938 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1939 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1940 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1941 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1942 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1943#define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1945 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1946 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1947#define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1948#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1949#define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1950#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1951#define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1952#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1953#define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1954#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1955#define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1956#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1957#define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1959#define JSON_HEDLEY_NEVER_INLINE
1962#if defined(JSON_HEDLEY_PRIVATE)
1963#undef JSON_HEDLEY_PRIVATE
1965#if defined(JSON_HEDLEY_PUBLIC)
1966#undef JSON_HEDLEY_PUBLIC
1968#if defined(JSON_HEDLEY_IMPORT)
1969#undef JSON_HEDLEY_IMPORT
1971#if defined(_WIN32) || defined(__CYGWIN__)
1972# define JSON_HEDLEY_PRIVATE
1973# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1974# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1977 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1978 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1979 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1980 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1981 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1982 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1984 defined(__TI_EABI__) && \
1986 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1987 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1990 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1991# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1992# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1994# define JSON_HEDLEY_PRIVATE
1995# define JSON_HEDLEY_PUBLIC
1997# define JSON_HEDLEY_IMPORT extern
2000#if defined(JSON_HEDLEY_NO_THROW)
2001#undef JSON_HEDLEY_NO_THROW
2004 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2005 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2006 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2007 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2008#define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2010 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2011 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2012 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2013#define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2015#define JSON_HEDLEY_NO_THROW
2018#if defined(JSON_HEDLEY_FALL_THROUGH)
2019#undef JSON_HEDLEY_FALL_THROUGH
2022 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2023 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2024 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2025#define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2026#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2027#define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2028#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2029#define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2030#elif defined(__fallthrough)
2031#define JSON_HEDLEY_FALL_THROUGH __fallthrough
2033#define JSON_HEDLEY_FALL_THROUGH
2036#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2037#undef JSON_HEDLEY_RETURNS_NON_NULL
2040 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2041 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2042 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2043#define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2044#elif defined(_Ret_notnull_)
2045#define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2047#define JSON_HEDLEY_RETURNS_NON_NULL
2050#if defined(JSON_HEDLEY_ARRAY_PARAM)
2051#undef JSON_HEDLEY_ARRAY_PARAM
2054 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2055 !defined(__STDC_NO_VLA__) && \
2056 !defined(__cplusplus) && \
2057 !defined(JSON_HEDLEY_PGI_VERSION) && \
2058 !defined(JSON_HEDLEY_TINYC_VERSION)
2059#define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2061#define JSON_HEDLEY_ARRAY_PARAM(name)
2064#if defined(JSON_HEDLEY_IS_CONSTANT)
2065#undef JSON_HEDLEY_IS_CONSTANT
2067#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2068#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2072#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2073#undef JSON_HEDLEY_IS_CONSTEXPR_
2076 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2077 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2078 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2079 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2080 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2081 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2082 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2083 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2084 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2085 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2086#define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2088#if !defined(__cplusplus)
2090 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2091 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2092 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2093 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2094 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2095 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2096 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2097#if defined(__INTPTR_TYPE__)
2098#define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2101#define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2105 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2106 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2107 !defined(JSON_HEDLEY_PGI_VERSION) && \
2108 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2109 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2110 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2111 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2112 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2113 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2114#if defined(__INTPTR_TYPE__)
2115#define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2118#define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2121 defined(JSON_HEDLEY_GCC_VERSION) || \
2122 defined(JSON_HEDLEY_INTEL_VERSION) || \
2123 defined(JSON_HEDLEY_TINYC_VERSION) || \
2124 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2125 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2126 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2127 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2128 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2129 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2131# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2135 ((void*) ((expr) * 0L) ) : \
2136((struct { char v[sizeof(void) * 2]; } *) 1) \
2142#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2143#if !defined(JSON_HEDLEY_IS_CONSTANT)
2144#define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2146#define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2148#if !defined(JSON_HEDLEY_IS_CONSTANT)
2149#define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2151#define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2154#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2155#undef JSON_HEDLEY_BEGIN_C_DECLS
2157#if defined(JSON_HEDLEY_END_C_DECLS)
2158#undef JSON_HEDLEY_END_C_DECLS
2160#if defined(JSON_HEDLEY_C_DECL)
2161#undef JSON_HEDLEY_C_DECL
2163#if defined(__cplusplus)
2164#define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2165#define JSON_HEDLEY_END_C_DECLS }
2166#define JSON_HEDLEY_C_DECL extern "C"
2168#define JSON_HEDLEY_BEGIN_C_DECLS
2169#define JSON_HEDLEY_END_C_DECLS
2170#define JSON_HEDLEY_C_DECL
2173#if defined(JSON_HEDLEY_STATIC_ASSERT)
2174#undef JSON_HEDLEY_STATIC_ASSERT
2177 !defined(__cplusplus) && ( \
2178 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2179 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2180 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2181 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2182 defined(_Static_assert) \
2184# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2186 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2187 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2188 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2189# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2191# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2194#if defined(JSON_HEDLEY_NULL)
2195#undef JSON_HEDLEY_NULL
2197#if defined(__cplusplus)
2198#if __cplusplus >= 201103L
2199#define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2201#define JSON_HEDLEY_NULL NULL
2203#define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2206#define JSON_HEDLEY_NULL NULL
2208#define JSON_HEDLEY_NULL ((void*) 0)
2211#if defined(JSON_HEDLEY_MESSAGE)
2212#undef JSON_HEDLEY_MESSAGE
2214#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2215# define JSON_HEDLEY_MESSAGE(msg) \
2216 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2217 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2218 JSON_HEDLEY_PRAGMA(message msg) \
2219 JSON_HEDLEY_DIAGNOSTIC_POP
2221 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2222 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2223# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2224#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2225# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2226#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2227# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2228#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2229# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2231# define JSON_HEDLEY_MESSAGE(msg)
2234#if defined(JSON_HEDLEY_WARNING)
2235#undef JSON_HEDLEY_WARNING
2237#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2238# define JSON_HEDLEY_WARNING(msg) \
2239 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2240 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2241 JSON_HEDLEY_PRAGMA(clang warning msg) \
2242 JSON_HEDLEY_DIAGNOSTIC_POP
2244 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2245 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2246 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2247# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2249 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2250 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2251# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2253# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2256#if defined(JSON_HEDLEY_REQUIRE)
2257#undef JSON_HEDLEY_REQUIRE
2259#if defined(JSON_HEDLEY_REQUIRE_MSG)
2260#undef JSON_HEDLEY_REQUIRE_MSG
2262#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2263# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2264# define JSON_HEDLEY_REQUIRE(expr) \
2265 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2266 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2267 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2268 JSON_HEDLEY_DIAGNOSTIC_POP
2269# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2270 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2271 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2272 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2273 JSON_HEDLEY_DIAGNOSTIC_POP
2275# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2276# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2279# define JSON_HEDLEY_REQUIRE(expr)
2280# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2283#if defined(JSON_HEDLEY_FLAGS)
2284#undef JSON_HEDLEY_FLAGS
2286#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2287#define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2289#define JSON_HEDLEY_FLAGS
2292#if defined(JSON_HEDLEY_FLAGS_CAST)
2293#undef JSON_HEDLEY_FLAGS_CAST
2295#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2296# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2297 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2298 _Pragma("warning(disable:188)") \
2300 JSON_HEDLEY_DIAGNOSTIC_POP \
2303# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2306#if defined(JSON_HEDLEY_EMPTY_BASES)
2307#undef JSON_HEDLEY_EMPTY_BASES
2310 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2311 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2312#define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2314#define JSON_HEDLEY_EMPTY_BASES
2319#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2320#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2322#if defined(__clang__)
2323#define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2325#define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2328#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2329#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2331#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2333#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2334#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2336#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2338#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2339#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2341#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2343#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2344#undef JSON_HEDLEY_CLANG_HAS_FEATURE
2346#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2348#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2349#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2351#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2353#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2354#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2356#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2358#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2359#undef JSON_HEDLEY_CLANG_HAS_WARNING
2361#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2373#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2374#if defined(__clang__)
2375#if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2376#error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2378#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2379#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2380#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2387#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2388#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2389#define JSON_HAS_CPP_20
2390#define JSON_HAS_CPP_17
2391#define JSON_HAS_CPP_14
2392#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2393#define JSON_HAS_CPP_17
2394#define JSON_HAS_CPP_14
2395#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2396#define JSON_HAS_CPP_14
2399#define JSON_HAS_CPP_11
2403#if __has_include(<version>)
2408#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2409#ifdef JSON_HAS_CPP_17
2410#if defined(__cpp_lib_filesystem)
2411#define JSON_HAS_FILESYSTEM 1
2412#elif defined(__cpp_lib_experimental_filesystem)
2413#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2414#elif !defined(__has_include)
2415#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2416#elif __has_include(<filesystem>)
2417#define JSON_HAS_FILESYSTEM 1
2418#elif __has_include(<experimental/filesystem>)
2419#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2423#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2424#undef JSON_HAS_FILESYSTEM
2425#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2429#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2430#undef JSON_HAS_FILESYSTEM
2431#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2435#if defined(__clang_major__) && __clang_major__ < 7
2436#undef JSON_HAS_FILESYSTEM
2437#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2441#if defined(_MSC_VER) && _MSC_VER < 1914
2442#undef JSON_HAS_FILESYSTEM
2443#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2447#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2448#undef JSON_HAS_FILESYSTEM
2449#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2453#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2454#undef JSON_HAS_FILESYSTEM
2455#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2460#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2461#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2464#ifndef JSON_HAS_FILESYSTEM
2465#define JSON_HAS_FILESYSTEM 0
2468#ifndef JSON_HAS_THREE_WAY_COMPARISON
2469#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2470 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2471#define JSON_HAS_THREE_WAY_COMPARISON 1
2473#define JSON_HAS_THREE_WAY_COMPARISON 0
2477#ifndef JSON_HAS_RANGES
2479#if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2480#define JSON_HAS_RANGES 0
2481#elif defined(__cpp_lib_ranges)
2482#define JSON_HAS_RANGES 1
2484#define JSON_HAS_RANGES 0
2488#ifdef JSON_HAS_CPP_17
2489#define JSON_INLINE_VARIABLE inline
2491#define JSON_INLINE_VARIABLE
2494#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2495#define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2497#define JSON_NO_UNIQUE_ADDRESS
2501#if defined(__clang__)
2502#pragma clang diagnostic push
2503#pragma clang diagnostic ignored "-Wdocumentation"
2504#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2508#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2509#define JSON_THROW(exception) throw exception
2511#define JSON_CATCH(exception) catch(exception)
2512#define JSON_INTERNAL_CATCH(exception) catch(exception)
2515#define JSON_THROW(exception) std::abort()
2516#define JSON_TRY if(true)
2517#define JSON_CATCH(exception) if(false)
2518#define JSON_INTERNAL_CATCH(exception) if(false)
2522#if defined(JSON_THROW_USER)
2524#define JSON_THROW JSON_THROW_USER
2526#if defined(JSON_TRY_USER)
2528#define JSON_TRY JSON_TRY_USER
2530#if defined(JSON_CATCH_USER)
2532#define JSON_CATCH JSON_CATCH_USER
2533#undef JSON_INTERNAL_CATCH
2534#define JSON_INTERNAL_CATCH JSON_CATCH_USER
2536#if defined(JSON_INTERNAL_CATCH_USER)
2537#undef JSON_INTERNAL_CATCH
2538#define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2542#if !defined(JSON_ASSERT)
2544#define JSON_ASSERT(x) assert(x)
2548#if defined(JSON_TESTS_PRIVATE)
2549#define JSON_PRIVATE_UNLESS_TESTED public
2551#define JSON_PRIVATE_UNLESS_TESTED private
2559#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2560 template<typename BasicJsonType> \
2561 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2563 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2564 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2565 auto it = std::find_if(std::begin(m), std::end(m), \
2566 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2568 return ej_pair.first == e; \
2570 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2572 template<typename BasicJsonType> \
2573 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2575 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2576 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2577 auto it = std::find_if(std::begin(m), std::end(m), \
2578 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2580 return ej_pair.second == j; \
2582 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2588#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2589 template<template<typename, typename, typename...> class ObjectType, \
2590 template<typename, typename...> class ArrayType, \
2591 class StringType, class BooleanType, class NumberIntegerType, \
2592 class NumberUnsignedType, class NumberFloatType, \
2593 template<typename> class AllocatorType, \
2594 template<typename, typename = void> class JSONSerializer, \
2596 class CustomBaseClass>
2598#define NLOHMANN_BASIC_JSON_TPL \
2599 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2600 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2601 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
2605#define NLOHMANN_JSON_EXPAND( x ) x
2606#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
2607#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2608 NLOHMANN_JSON_PASTE64, \
2609 NLOHMANN_JSON_PASTE63, \
2610 NLOHMANN_JSON_PASTE62, \
2611 NLOHMANN_JSON_PASTE61, \
2612 NLOHMANN_JSON_PASTE60, \
2613 NLOHMANN_JSON_PASTE59, \
2614 NLOHMANN_JSON_PASTE58, \
2615 NLOHMANN_JSON_PASTE57, \
2616 NLOHMANN_JSON_PASTE56, \
2617 NLOHMANN_JSON_PASTE55, \
2618 NLOHMANN_JSON_PASTE54, \
2619 NLOHMANN_JSON_PASTE53, \
2620 NLOHMANN_JSON_PASTE52, \
2621 NLOHMANN_JSON_PASTE51, \
2622 NLOHMANN_JSON_PASTE50, \
2623 NLOHMANN_JSON_PASTE49, \
2624 NLOHMANN_JSON_PASTE48, \
2625 NLOHMANN_JSON_PASTE47, \
2626 NLOHMANN_JSON_PASTE46, \
2627 NLOHMANN_JSON_PASTE45, \
2628 NLOHMANN_JSON_PASTE44, \
2629 NLOHMANN_JSON_PASTE43, \
2630 NLOHMANN_JSON_PASTE42, \
2631 NLOHMANN_JSON_PASTE41, \
2632 NLOHMANN_JSON_PASTE40, \
2633 NLOHMANN_JSON_PASTE39, \
2634 NLOHMANN_JSON_PASTE38, \
2635 NLOHMANN_JSON_PASTE37, \
2636 NLOHMANN_JSON_PASTE36, \
2637 NLOHMANN_JSON_PASTE35, \
2638 NLOHMANN_JSON_PASTE34, \
2639 NLOHMANN_JSON_PASTE33, \
2640 NLOHMANN_JSON_PASTE32, \
2641 NLOHMANN_JSON_PASTE31, \
2642 NLOHMANN_JSON_PASTE30, \
2643 NLOHMANN_JSON_PASTE29, \
2644 NLOHMANN_JSON_PASTE28, \
2645 NLOHMANN_JSON_PASTE27, \
2646 NLOHMANN_JSON_PASTE26, \
2647 NLOHMANN_JSON_PASTE25, \
2648 NLOHMANN_JSON_PASTE24, \
2649 NLOHMANN_JSON_PASTE23, \
2650 NLOHMANN_JSON_PASTE22, \
2651 NLOHMANN_JSON_PASTE21, \
2652 NLOHMANN_JSON_PASTE20, \
2653 NLOHMANN_JSON_PASTE19, \
2654 NLOHMANN_JSON_PASTE18, \
2655 NLOHMANN_JSON_PASTE17, \
2656 NLOHMANN_JSON_PASTE16, \
2657 NLOHMANN_JSON_PASTE15, \
2658 NLOHMANN_JSON_PASTE14, \
2659 NLOHMANN_JSON_PASTE13, \
2660 NLOHMANN_JSON_PASTE12, \
2661 NLOHMANN_JSON_PASTE11, \
2662 NLOHMANN_JSON_PASTE10, \
2663 NLOHMANN_JSON_PASTE9, \
2664 NLOHMANN_JSON_PASTE8, \
2665 NLOHMANN_JSON_PASTE7, \
2666 NLOHMANN_JSON_PASTE6, \
2667 NLOHMANN_JSON_PASTE5, \
2668 NLOHMANN_JSON_PASTE4, \
2669 NLOHMANN_JSON_PASTE3, \
2670 NLOHMANN_JSON_PASTE2, \
2671 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2672#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2673#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2674#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2675#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2676#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2677#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2678#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2679#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2680#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2681#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2682#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2683#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2684#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2685#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2686#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2687#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2688#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2689#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2690#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2691#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2692#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
2693#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
2694#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
2695#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
2696#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
2697#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
2698#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
2699#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
2700#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
2701#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2702#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2703#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2704#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2705#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2706#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2707#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2708#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2709#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2710#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
2711#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
2712#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
2713#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
2714#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
2715#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
2716#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
2717#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
2718#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
2719#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2720#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2721#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2722#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2723#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2724#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2725#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2726#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2727#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2728#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
2729#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
2730#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
2731#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
2732#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
2733#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
2734#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
2736#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2737#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2738#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1);
2745#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2746 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2747 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2749#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2750 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2751 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2758#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2759 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2760 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2762#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2763 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2764 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2773#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2774 namespace detail { \
2775 using std::std_name; \
2777 template<typename... T> \
2778 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2781 namespace detail2 { \
2782 struct std_name##_tag \
2786 template<typename... T> \
2787 std_name##_tag std_name(T&&...); \
2789 template<typename... T> \
2790 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2792 template<typename... T> \
2793 struct would_call_std_##std_name \
2795 static constexpr auto const value = ::nlohmann::detail:: \
2796 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2800 template<typename... T> \
2801 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2805#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2806#define JSON_USE_IMPLICIT_CONVERSIONS 1
2809#if JSON_USE_IMPLICIT_CONVERSIONS
2810#define JSON_EXPLICIT
2812#define JSON_EXPLICIT explicit
2815#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2816#define JSON_DISABLE_ENUM_SERIALIZATION 0
2819#ifndef JSON_USE_GLOBAL_UDLS
2820#define JSON_USE_GLOBAL_UDLS 1
2823#if JSON_HAS_THREE_WAY_COMPARISON
2886#if JSON_HAS_THREE_WAY_COMPARISON
2887 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
2892 static constexpr std::array<std::uint8_t, 9> order = { {
2899 const auto l_index =
static_cast<std::size_t
>(lhs);
2900 const auto r_index =
static_cast<std::size_t
>(rhs);
2901#if JSON_HAS_THREE_WAY_COMPARISON
2902 if (l_index < order.size() && r_index < order.size())
2904 return order[l_index] <=> order[r_index];
2906 return std::partial_ordering::unordered;
2908 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
2916#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
2919 return std::is_lt(lhs <=> rhs);
2957 template<
typename StringType>
2959 const StringType& t)
2962 for (
auto pos = s.find(f);
2963 pos != StringType::npos;
2964 s.replace(pos, f.size(), t),
2965 pos = s.find(f, pos + t.size()))
2977 template<
typename StringType>
2992 template<
typename StringType>
2993 static void unescape(StringType& s)
3033 constexpr operator size_t()
const
3058#include <type_traits>
3068 template<
typename T>
3069 using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3071#ifdef JSON_HAS_CPP_14
3074 using std::enable_if_t;
3075 using std::index_sequence;
3076 using std::make_index_sequence;
3077 using std::index_sequence_for;
3082 template<
bool B,
typename T =
void>
3109 template <
typename T, T... Ints>
3113 static constexpr std::size_t
size() noexcept
3115 return sizeof...(Ints);
3124 template <
size_t... Ints>
3127 namespace utility_internal
3130 template <
typename Seq,
size_t SeqSize,
size_t Rem>
3134 template <
typename T, T... Ints,
size_t SeqSize>
3140 template <
typename T, T... Ints,
size_t SeqSize>
3148 template <
typename T,
size_t N>
3155 template <
typename T>
3170 template <
typename T, T N>
3186 template <
typename... Ts>
3198 template<
typename T>
3204#ifndef JSON_HAS_CPP_17
3205 template<
typename T>
3209 template<
typename T,
typename... Args>
3210 inline constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3212 return std::array<T,
sizeof...(Args)> { {
static_cast<T
>(std::forward<Args>(args))...}};
3230#include <type_traits>
3258 template<
typename It,
typename =
void>
3261 template<
typename It>
3265 typename It::reference, typename It::iterator_category >>
3276 template<
typename T,
typename =
void>
3281 template<
typename T>
3287 template<
typename T>
3355#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3356#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3381template<
typename T =
void,
typename SFINAE =
void>
3386template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3388 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3389 class StringType = std::string,
class BooleanType = bool,
3390 class NumberIntegerType = std::int64_t,
3391 class NumberUnsignedType = std::uint64_t,
3392 class NumberFloatType = double,
3393 template<
typename U>
class AllocatorType = std::allocator,
3394 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3396 class BinaryType = std::vector<std::uint8_t>,
3397 class CustomBaseClass =
void>
3402template<
typename RefStringType>
3413template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3458 template<
typename BasicJsonContext>
3460 std::integral_constant < bool,
3461 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3462 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3475 template<
typename T>
3482 template<
typename T>
3485 template<
typename T>
3488 template<
typename T>
3491 template<
typename T>
3494 template<
typename T>
3497 template<
typename T>
3500 template<
typename T>
3503 template<
typename T,
typename... Args>
3506 template<
typename T,
typename... Args>
3509 template<
typename T,
typename U>
3513 template<
typename BasicJsonType,
typename T,
typename =
void>
3520 template <
typename BasicJsonType,
typename T>
3526 template<
typename BasicJsonType,
typename T>
3529 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3533 const BasicJsonType&, T&>
::value;
3538 template<
typename BasicJsonType,
typename T,
typename =
void>
3541 template<
typename BasicJsonType,
typename T>
3544 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3553 template<
typename BasicJsonType,
typename T,
typename =
void>
3556 template<
typename BasicJsonType,
typename T>
3559 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3566 template<
typename T>
3569 template<
typename T>
3570 struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3573 template<
typename BasicJsonType>
3578 using type =
typename std::conditional < has_key_compare<object_t>::value,
3582 template<
typename BasicJsonType>
3592 template<
class B,
class... Bn>
3594 : std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
3597 template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3602 template <
typename T>
3605 template <
typename T1,
typename T2>
3607 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3609 template <
typename T1,
typename T2>
3611 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3613 template <
typename... Ts>
3615 :
conjunction<is_default_constructible<Ts>...> {};
3617 template <
typename... Ts>
3619 :
conjunction<is_default_constructible<Ts>...> {};
3622 template <
typename T,
typename... Args>
3625 template <
typename T1,
typename T2>
3628 template <
typename T1,
typename T2>
3631 template <
typename... Ts>
3634 template <
typename... Ts>
3638 template<
typename T,
typename =
void>
3641 template<
typename T>
3656 template<
typename T>
3660 using t_ref =
typename std::add_lvalue_reference<T>::type;
3668 static constexpr auto is_iterator_begin =
3672 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value&& is_iterator_begin;
3675 template<
typename R>
3678 template<
typename T>
3685 template<
typename T,
typename =
void>
3688 template<
typename T>
3691 template<
typename BasicJsonType,
typename CompatibleObjectType,
3695 template<
typename BasicJsonType,
typename CompatibleObjectType>
3697 BasicJsonType, CompatibleObjectType,
3706 typename CompatibleObjectType::key_type>
::value&&
3708 typename CompatibleObjectType::mapped_type>
::value;
3711 template<
typename BasicJsonType,
typename CompatibleObjectType>
3715 template<
typename BasicJsonType,
typename ConstructibleObjectType,
3719 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3721 BasicJsonType, ConstructibleObjectType,
3729 (std::is_move_assignable<ConstructibleObjectType>::value ||
3730 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3732 typename object_t::key_type>
::value &&
3734 typename object_t::mapped_type,
3735 typename ConstructibleObjectType::mapped_type >
::value)) ||
3737 typename ConstructibleObjectType::mapped_type>
::value ||
3740 typename ConstructibleObjectType::mapped_type >
::value);
3743 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3746 ConstructibleObjectType> {};
3748 template<
typename BasicJsonType,
typename CompatibleStringType>
3755 template<
typename BasicJsonType,
typename ConstructibleStringType>
3759#ifdef __INTEL_COMPILER
3760 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3772 template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3775 template<
typename BasicJsonType,
typename CompatibleArrayType>
3777 BasicJsonType, CompatibleArrayType,
3783 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
3790 template<
typename BasicJsonType,
typename CompatibleArrayType>
3794 template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3797 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3799 BasicJsonType, ConstructibleArrayType,
3801 typename BasicJsonType::value_type>
::value >>
3802 : std::true_type {};
3804 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3806 BasicJsonType, ConstructibleArrayType,
3808 typename BasicJsonType::value_type>
::value &&
3811 (std::is_move_assignable<ConstructibleArrayType>::value ||
3812 std::is_copy_assignable<ConstructibleArrayType>::value) &&
3818 !std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
3820 detected_t<range_value_t, ConstructibleArrayType >>
::value >>
3826 typename BasicJsonType::array_t::value_type>
::value ||
3834 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3838 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3842 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3844 RealIntegerType, CompatibleNumberIntegerType,
3846 std::is_integral<CompatibleNumberIntegerType>
::value &&
3847 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
3855 CompatibleNumberIntegerType>
::value&&
3856 CompatibleLimits::is_integer&&
3857 RealLimits::is_signed == CompatibleLimits::is_signed;
3860 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3863 CompatibleNumberIntegerType> {};
3865 template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3868 template<
typename BasicJsonType,
typename CompatibleType>
3870 BasicJsonType, CompatibleType,
3877 template<
typename BasicJsonType,
typename CompatibleType>
3881 template<
typename T1,
typename T2>
3884 template<
typename T1,
typename... Args>
3887 template<
typename BasicJsonType,
typename T>
3890 template<
typename BasicJsonType>
3893 template<
typename BasicJsonType>
3898 template<
template <
typename...>
class Primary,
typename T>
3901 template<
template <
typename...>
class Primary,
typename... Args>
3904 template<
typename T>
3908 template<
typename Compare,
typename A,
typename B,
typename =
void>
3911 template<
typename Compare,
typename A,
typename B>
3913 decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
3914 decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
3915 >> : std::true_type {};
3917 template<
typename T>
3922 template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3926 && !(ExcludeObjectKeyType&& std::is_same<KeyType,
3928 && (!RequireTransparentComparator
3929 || is_detected <detect_is_transparent, Comparator>::value)
3932 std::false_type >::type;
3940 template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3944 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
3945 RequireTransparentComparator, ExcludeObjectKeyType>
::value
3948 std::false_type >::type;
3950 template<
typename ObjectType,
typename KeyType>
3954 template<
typename BasicJsonType,
typename KeyType>
3958 typename BasicJsonType::object_t, KeyType >
::value,
3960 std::false_type >::type;
3964 template <
typename T>
3974 template <
typename C>
static one test(
decltype(&C::capacity));
3977 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
3981 template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3984 return static_cast<T
>(
value);
3987 template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3993 template<
typename... Types>
3996 template<
typename... Types>
3999 template<
typename... Types>
4003 template<
typename... Types>
4007 template<
typename OfType,
typename T>
4009 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
4012 template<
typename OfType,
typename T,
4013 bool OfTypeSigned = std::is_signed<OfType>::value,
4014 bool TSigned = std::is_signed<T>::value>
4017 template<
typename OfType,
typename T>
4022 using CommonType =
typename std::common_type<OfType, T>::type;
4023 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4027 template<
typename OfType,
typename T>
4032 using CommonType =
typename std::common_type<OfType, T>::type;
4033 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4037 template<
typename OfType,
typename T>
4042 using CommonType =
typename std::common_type<OfType, T>::type;
4043 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4048 template<
typename OfType,
typename T>
4053 using CommonType =
typename std::common_type<OfType, T>::type;
4054 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4055 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4059 template<
typename OfType,
typename T,
4060 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
4064 template<
typename OfType,
typename T>
4073 template<
typename OfType,
typename T>
4082 template<
typename OfType,
typename T>
4088 template<
bool Value>
4098 template<
typename T>
4101 using TUnExt =
typename std::remove_extent<T>::type;
4102 using TUnCVExt =
typename std::remove_cv<TUnExt>::type;
4103 using TUnPtr =
typename std::remove_pointer<T>::type;
4104 using TUnCVPtr =
typename std::remove_cv<TUnPtr>::type;
4106 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
4107 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
4113 template<
typename T>
4116 template<
typename T>
4126 template<
typename T>
4135 template<
typename T>
4172 template<
typename... Args>
4173 inline std::size_t
concat_length(
const char* cstr,
const Args& ... rest);
4175 template<
typename StringType,
typename... Args>
4176 inline std::size_t
concat_length(
const StringType& str,
const Args& ... rest);
4178 template<
typename... Args>
4184 template<
typename... Args>
4191 template<
typename StringType,
typename... Args>
4197 template<
typename OutStringType>
4201 template<
typename StringType,
typename Arg>
4204 template<
typename StringType,
typename Arg>
4207 template<
typename StringType,
typename Arg>
4210 template<
typename StringType,
typename Arg>
4213 template<
typename StringType,
typename Arg>
4214 using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4216 template<
typename StringType,
typename Arg>
4219 template<
typename StringType,
typename Arg>
4220 using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
4222 template<
typename StringType,
typename Arg>
4225 template <
typename OutStringType,
typename Arg,
typename... Args,
4226 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4228 inline void concat_into(OutStringType& out, Arg&& arg, Args && ... rest);
4230 template <
typename OutStringType,
typename Arg,
typename... Args,
4231 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4234 inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4236 template <
typename OutStringType,
typename Arg,
typename... Args,
4237 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4241 inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4243 template<
typename OutStringType,
typename Arg,
typename... Args,
4245 inline void concat_into(OutStringType& out, Arg&& arg, Args && ... rest)
4247 out.append(std::forward<Arg>(arg));
4251 template <
typename OutStringType,
typename Arg,
typename... Args,
4252 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4253 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
4254 inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4256 out += std::forward<Arg>(arg);
4260 template <
typename OutStringType,
typename Arg,
typename... Args,
4261 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4262 && !detect_string_can_append_op<OutStringType, Arg>::value
4263 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
4264 inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4266 out.append(arg.begin(), arg.end());
4270 template <
typename OutStringType,
typename Arg,
typename... Args,
4271 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4272 && !detect_string_can_append_op<OutStringType, Arg>::value
4273 && !detect_string_can_append_iter<OutStringType, Arg>::value
4274 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4275 inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4277 out.append(arg.data(), arg.size());
4281 template<
typename OutStringType = std::string,
typename... Args>
4282 inline OutStringType
concat(Args && ... args)
4309 const char*
what() const noexcept
override
4319 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
4321 static std::string
name(
const std::string& ename,
int id_)
4323 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
4331 template<
typename BasicJsonType>
4335 std::vector<std::string> tokens;
4336 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4338 switch (current->m_parent->type())
4342 for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
4344 if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
4346 tokens.emplace_back(std::to_string(i));
4355 for (
const auto& element : *current->m_parent->m_data.m_value.object)
4357 if (&element.second == current)
4359 tokens.emplace_back(element.first.c_str());
4384 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4385 [](
const std::string& a,
const std::string& b)
4387 return concat(a,
'/', detail::escape(b));
4389 return concat(
'(', str,
") ");
4391 static_cast<void>(leaf_element);
4398 std::runtime_error m;
4415 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4423 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4424 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4427 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
4429 return { id_, byte_, w.c_str() };
4444 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
4447 static std::string position_string(
const position_t& pos)
4459 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4463 return { id_, w.c_str() };
4477 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4481 return { id_, w.c_str() };
4494 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4498 return { id_, w.c_str() };
4511 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4515 return { id_, w.c_str() };
4568#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4569#include <experimental/filesystem>
4573 namespace std_fs = std::experimental::filesystem;
4576#elif JSON_HAS_FILESYSTEM
4577#include <filesystem>
4581 namespace std_fs = std::filesystem;
4597 template<
typename BasicJsonType>
4598 inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4608 template <
typename BasicJsonType,
typename ArithmeticType,
4609 enable_if_t < std::is_arithmetic<ArithmeticType>::value &&
4610 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4614 switch (
static_cast<value_t>(j))
4618 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4623 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4628 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4644 template<
typename BasicJsonType>
4645 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4651 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4654 template<
typename BasicJsonType>
4655 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4661 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4665 typename BasicJsonType,
typename StringType,
4667 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4668 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
4669 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4670 && !is_json_ref<StringType>::value,
int > = 0 >
4671 inline void from_json(
const BasicJsonType& j, StringType& s)
4678 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4681 template<
typename BasicJsonType>
4682 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4687 template<
typename BasicJsonType>
4688 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4693 template<
typename BasicJsonType>
4694 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4699#if !JSON_DISABLE_ENUM_SERIALIZATION
4700 template<
typename BasicJsonType,
typename EnumType,
4701 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4704 typename std::underlying_type<EnumType>::type val;
4706 e =
static_cast<EnumType
>(val);
4711 template<
typename BasicJsonType,
typename T,
typename Allocator,
4712 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4713 inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4720 std::transform(j.rbegin(), j.rend(),
4721 std::front_inserter(l), [](
const BasicJsonType& i)
4723 return i.template get<T>();
4728 template<
typename BasicJsonType,
typename T,
4729 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4730 inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
4737 std::transform(j.begin(), j.end(), std::begin(l),
4738 [](
const BasicJsonType& elem)
4740 return elem.template get<T>();
4744 template<
typename BasicJsonType,
typename T, std::
size_t N>
4746 ->
decltype(j.template get<T>(), void())
4748 for (std::size_t i = 0; i < N; ++i)
4750 arr[i] = j.at(i).template get<T>();
4754 template<
typename BasicJsonType>
4757 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4760 template<
typename BasicJsonType,
typename T, std::
size_t N>
4763 ->
decltype(j.template get<T>(), void())
4765 for (std::size_t i = 0; i < N; ++i)
4767 arr[i] = j.at(i).template get<T>();
4771 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4773 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4777 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4778 j.template get<typename ConstructibleArrayType::value_type>(),
4783 ConstructibleArrayType ret;
4784 ret.reserve(j.size());
4785 std::transform(j.begin(), j.end(),
4786 std::inserter(ret, end(ret)), [](
const BasicJsonType& i)
4790 return i.template get<typename ConstructibleArrayType::value_type>();
4792 arr = std::move(ret);
4795 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4797 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4804 ConstructibleArrayType ret;
4806 j.begin(), j.end(), std::inserter(ret, end(ret)),
4807 [](
const BasicJsonType& i)
4811 return i.template get<typename ConstructibleArrayType::value_type>();
4813 arr = std::move(ret);
4816 template <
typename BasicJsonType,
typename ConstructibleArrayType,
4818 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value &&
4819 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value &&
4821 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value &&
4822 !is_basic_json<ConstructibleArrayType>::value,
4824 auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4826 j.template get<typename ConstructibleArrayType::value_type>(),
4837 template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4841 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4844 template <
typename BasicJsonType,
typename T, std::
size_t N >
4856 template<
typename BasicJsonType>
4857 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4864 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4867 template<
typename BasicJsonType,
typename ConstructibleObjectType,
4868 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
4869 inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4876 ConstructibleObjectType ret;
4877 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4878 using value_type =
typename ConstructibleObjectType::value_type;
4880 inner_object->begin(), inner_object->end(),
4881 std::inserter(ret, ret.begin()),
4882 [](
typename BasicJsonType::object_t::value_type
const& p)
4884 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4886 obj = std::move(ret);
4893 template <
typename BasicJsonType,
typename ArithmeticType,
4895 std::is_arithmetic<ArithmeticType>::value &&
4896 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value &&
4897 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value &&
4898 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value &&
4899 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4901 inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
4903 switch (
static_cast<value_t>(j))
4907 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4912 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4917 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4922 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4937 template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4940 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4943 template <
typename BasicJsonType,
class A1,
class A2 >
4946 return { std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4947 std::forward<BasicJsonType>(j).at(1).template get<A2>() };
4950 template<
typename BasicJsonType,
typename A1,
typename A2>
4956 template<
typename BasicJsonType,
typename... Args>
4962 template<
typename BasicJsonType,
typename... Args>
4968 template<
typename BasicJsonType,
typename TupleRelated>
4977 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4980 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4982 typename BasicJsonType::string_t, Key >
::value >>
4983 inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4990 for (
const auto& p : j)
4996 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5000 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5002 typename BasicJsonType::string_t, Key >
::value >>
5003 inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5010 for (
const auto& p : j)
5016 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5020#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5021 template<
typename BasicJsonType>
5022 inline void from_json(
const BasicJsonType& j, std_fs::path& p)
5028 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5034 template<
typename BasicJsonType,
typename T>
5036 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
5037 ->
decltype(
from_json(j, std::forward<T>(val)))
5039 return from_json(j, std::forward<T>(val));
5045#ifndef JSON_HAS_CPP_17
5054#ifndef JSON_HAS_CPP_17
5075#include <type_traits>
5112 template<
typename string_type>
5116 using std::to_string;
5127 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype(std::declval<IteratorType>().
key()) >::type >::type;
5131 IteratorType anchor{};
5133 std::size_t array_index = 0;
5135 mutable std::size_t array_index_last = 0;
5144 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5146 : anchor(
std::move(it))
5147 , array_index(array_index_)
5154 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5157 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5187 return anchor == o.anchor;
5193 return anchor != o.anchor;
5201 switch (anchor.m_object->type())
5206 if (array_index != array_index_last)
5209 array_index_last = array_index;
5211 return array_index_str;
5216 return anchor.key();
5233 typename IteratorType::reference
value()
const
5235 return anchor.value();
5244 typename IteratorType::pointer container =
nullptr;
5251 : container(&cont) {}
5275 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5276 auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
5283 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5284 auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
5299#if defined(__clang__)
5301#pragma clang diagnostic push
5302#pragma clang diagnostic ignored "-Wmismatched-tags"
5304 template<
typename IteratorType>
5305 class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5306 :
public std::integral_constant<std::size_t, 2> {};
5308 template<std::
size_t N,
typename IteratorType>
5309 class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5313 get<N>(std::declval <
5314 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5316#if defined(__clang__)
5317#pragma clang diagnostic pop
5323template <
typename IteratorType>
5324inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5358 template<
typename BasicJsonType>
5359 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
5361 j.m_data.m_value.destroy(j.m_data.m_type);
5363 j.m_data.m_value = b;
5364 j.assert_invariant();
5371 template<
typename BasicJsonType>
5372 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5374 j.m_data.m_value.destroy(j.m_data.m_type);
5376 j.m_data.m_value = s;
5377 j.assert_invariant();
5380 template<
typename BasicJsonType>
5381 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5383 j.m_data.m_value.destroy(j.m_data.m_type);
5385 j.m_data.m_value = std::move(s);
5386 j.assert_invariant();
5389 template <
typename BasicJsonType,
typename CompatibleStringType,
5390 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
5392 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5394 j.m_data.m_value.destroy(j.m_data.m_type);
5396 j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5397 j.assert_invariant();
5404 template<
typename BasicJsonType>
5405 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5407 j.m_data.m_value.destroy(j.m_data.m_type);
5409 j.m_data.m_value =
typename BasicJsonType::binary_t(b);
5410 j.assert_invariant();
5413 template<
typename BasicJsonType>
5414 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5416 j.m_data.m_value.destroy(j.m_data.m_type);
5418 j.m_data.m_value =
typename BasicJsonType::binary_t(std::move(b));
5419 j.assert_invariant();
5426 template<
typename BasicJsonType>
5427 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5429 j.m_data.m_value.destroy(j.m_data.m_type);
5431 j.m_data.m_value = val;
5432 j.assert_invariant();
5439 template<
typename BasicJsonType>
5440 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5442 j.m_data.m_value.destroy(j.m_data.m_type);
5444 j.m_data.m_value = val;
5445 j.assert_invariant();
5452 template<
typename BasicJsonType>
5453 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5455 j.m_data.m_value.destroy(j.m_data.m_type);
5457 j.m_data.m_value = val;
5458 j.assert_invariant();
5465 template<
typename BasicJsonType>
5466 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5468 j.m_data.m_value.destroy(j.m_data.m_type);
5470 j.m_data.m_value = arr;
5472 j.assert_invariant();
5475 template<
typename BasicJsonType>
5476 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5478 j.m_data.m_value.destroy(j.m_data.m_type);
5480 j.m_data.m_value = std::move(arr);
5482 j.assert_invariant();
5485 template <
typename BasicJsonType,
typename CompatibleArrayType,
5486 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
5488 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5493 j.m_data.m_value.destroy(j.m_data.m_type);
5495 j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
5497 j.assert_invariant();
5500 template<
typename BasicJsonType>
5501 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5503 j.m_data.m_value.destroy(j.m_data.m_type);
5506 j.m_data.m_value.array->reserve(arr.size());
5507 for (
const bool x : arr)
5509 j.m_data.m_value.array->push_back(x);
5510 j.set_parent(j.m_data.m_value.array->back());
5512 j.assert_invariant();
5515 template<
typename BasicJsonType,
typename T,
5517 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5519 j.m_data.m_value.destroy(j.m_data.m_type);
5522 j.m_data.m_value.array->resize(arr.size());
5525 std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin());
5528 j.assert_invariant();
5535 template<
typename BasicJsonType>
5536 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5538 j.m_data.m_value.destroy(j.m_data.m_type);
5540 j.m_data.m_value = obj;
5542 j.assert_invariant();
5545 template<
typename BasicJsonType>
5546 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5548 j.m_data.m_value.destroy(j.m_data.m_type);
5550 j.m_data.m_value = std::move(obj);
5552 j.assert_invariant();
5555 template <
typename BasicJsonType,
typename CompatibleObjectType,
5556 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
5557 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5562 j.m_data.m_value.destroy(j.m_data.m_type);
5564 j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5566 j.assert_invariant();
5574 template<
typename BasicJsonType,
typename T,
5575 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5576 inline void to_json(BasicJsonType& j, T b)
noexcept
5581 template <
typename BasicJsonType,
typename BoolRef,
5583 ((std::is_same<std::vector<bool>::reference, BoolRef>
::value
5584 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>
::value)
5585 || (std::is_same<std::vector<bool>::const_reference, BoolRef>
::value
5587 typename BasicJsonType::boolean_t >
::value))
5588 && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
int > = 0 >
5589 inline void to_json(BasicJsonType& j,
const BoolRef& b)
noexcept
5594 template<
typename BasicJsonType,
typename CompatibleString,
5595 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5596 inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5601 template<
typename BasicJsonType>
5602 inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5607 template<
typename BasicJsonType,
typename FloatType,
5608 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5609 inline void to_json(BasicJsonType& j, FloatType val)
noexcept
5614 template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5615 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5616 inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
5621 template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5622 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5623 inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
5628#if !JSON_DISABLE_ENUM_SERIALIZATION
5629 template<
typename BasicJsonType,
typename EnumType,
5630 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5631 inline void to_json(BasicJsonType& j, EnumType e)
noexcept
5633 using underlying_type =
typename std::underlying_type<EnumType>::type;
5638 template<
typename BasicJsonType>
5639 inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5644 template <
typename BasicJsonType,
typename CompatibleArrayType,
5645 enable_if_t < is_compatible_array_type<BasicJsonType,
5646 CompatibleArrayType>
::value &&
5647 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value &&
5649 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value &&
5650 !is_basic_json<CompatibleArrayType>::value,
5652 inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
5657 template<
typename BasicJsonType>
5658 inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5663 template<
typename BasicJsonType,
typename T,
5664 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5665 inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
5670 template<
typename BasicJsonType>
5671 inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5676 template <
typename BasicJsonType,
typename CompatibleObjectType,
5677 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value && !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
5678 inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5683 template<
typename BasicJsonType>
5684 inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5690 typename BasicJsonType,
typename T, std::size_t N,
5691 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
5694 inline void to_json(BasicJsonType& j,
const T(&arr)[N])
5699 template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
5700 inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
5702 j = { p.first, p.second };
5706 template<
typename BasicJsonType,
typename T,
5707 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>
::value,
int> = 0>
5710 j = { {b.key(), b.value()} };
5713 template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5716 j = { std::get<Idx>(t)... };
5719 template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
5720 inline void to_json(BasicJsonType& j,
const T& t)
5725#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5726 template<
typename BasicJsonType>
5727 inline void to_json(BasicJsonType& j,
const std_fs::path& p)
5735 template<
typename BasicJsonType,
typename T>
5736 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
5737 ->
decltype(
to_json(j, std::forward<T>(val)), void())
5739 return to_json(j, std::forward<T>(val));
5744#ifndef JSON_HAS_CPP_17
5753#ifndef JSON_HAS_CPP_17
5765template<
typename ValueType,
typename>
5770 template<
typename BasicJsonType,
typename TargetType = ValueType>
5771 static auto from_json(BasicJsonType&& j, TargetType& val)
noexcept(
5772 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
5773 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
5775 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
5780 template<
typename BasicJsonType,
typename TargetType = ValueType>
5790 template<
typename BasicJsonType,
typename TargetType = ValueType>
5791 static auto to_json(BasicJsonType& j, TargetType&& val)
noexcept(
5792 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
5793 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
5795 ::nlohmann::to_json(j, std::forward<TargetType>(val));
5823template<
typename BinaryType>
5848 , m_subtype(subtype_)
5849 , m_has_subtype(
true)
5855 , m_subtype(subtype_)
5856 , m_has_subtype(
true)
5861 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
5862 std::tie(
static_cast<const BinaryType&
>(rhs), rhs.m_subtype, rhs.m_has_subtype);
5867 return !(rhs == *
this);
5874 m_subtype = subtype_;
5875 m_has_subtype =
true;
5882 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
5889 return m_has_subtype;
5897 m_has_subtype =
false;
5902 bool m_has_subtype =
false;
5926#include <functional>
5938 inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
5940 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5955 template<
typename BasicJsonType>
5956 std::size_t
hash(
const BasicJsonType& j)
5958 using string_t =
typename BasicJsonType::string_t;
5959 using number_integer_t =
typename BasicJsonType::number_integer_t;
5960 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5961 using number_float_t =
typename BasicJsonType::number_float_t;
5963 const auto type =
static_cast<std::size_t
>(j.type());
5966 case BasicJsonType::value_t::null:
5967 case BasicJsonType::value_t::discarded:
5972 case BasicJsonType::value_t::object:
5974 auto seed =
combine(type, j.size());
5975 for (
const auto& element : j.items())
5977 const auto h = std::hash<string_t>{}(element.key());
5984 case BasicJsonType::value_t::array:
5986 auto seed =
combine(type, j.size());
5987 for (
const auto& element : j)
5994 case BasicJsonType::value_t::string:
5996 const auto h = std::hash<string_t>{}(j.template get_ref<const string_t&>());
6000 case BasicJsonType::value_t::boolean:
6002 const auto h = std::hash<bool>{}(j.template get<bool>());
6006 case BasicJsonType::value_t::number_integer:
6008 const auto h = std::hash<number_integer_t>{}(j.template get<number_integer_t>());
6012 case BasicJsonType::value_t::number_unsigned:
6014 const auto h = std::hash<number_unsigned_t>{}(j.template get<number_unsigned_t>());
6018 case BasicJsonType::value_t::number_float:
6020 const auto h = std::hash<number_float_t>{}(j.template get<number_float_t>());
6024 case BasicJsonType::value_t::binary:
6026 auto seed =
combine(type, j.get_binary().size());
6027 const auto h = std::hash<bool>{}(j.get_binary().has_subtype());
6029 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
6030 for (
const auto byte : j.get_binary())
6032 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
6090#include <type_traits>
6140 return std::fgetc(m_file);
6169 is->clear(is->rdstate() & std::ios::eofbit);
6174 : is(&i), sb(i.rdbuf())
6183 : is(rhs.is), sb(rhs.sb)
6194 auto res = sb->sbumpc();
6198 is->clear(is->rdstate() | std::ios::eofbit);
6205 std::istream* is =
nullptr;
6206 std::streambuf* sb =
nullptr;
6212 template<
typename IteratorType>
6216 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6219 : current(
std::move(first)), end(
std::move(last))
6226 auto result = std::char_traits<char_type>::to_int_type(*current);
6227 std::advance(current, 1);
6231 return std::char_traits<char_type>::eof();
6235 IteratorType current;
6238 template<
typename BaseInputAdapter,
size_t T>
6243 return current == end;
6248 template<
typename BaseInputAdapter,
size_t T>
6251 template<
typename BaseInputAdapter>
6256 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6257 size_t& utf8_bytes_index,
6258 size_t& utf8_bytes_filled)
6260 utf8_bytes_index = 0;
6264 utf8_bytes[0] = std::char_traits<char>::eof();
6265 utf8_bytes_filled = 1;
6270 const auto wc = input.get_character();
6275 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6276 utf8_bytes_filled = 1;
6278 else if (wc <= 0x7FF)
6280 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6281 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6282 utf8_bytes_filled = 2;
6284 else if (wc <= 0xFFFF)
6286 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6287 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6288 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6289 utf8_bytes_filled = 3;
6291 else if (wc <= 0x10FFFF)
6293 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6294 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6295 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6296 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6297 utf8_bytes_filled = 4;
6302 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6303 utf8_bytes_filled = 1;
6309 template<
typename BaseInputAdapter>
6314 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6315 size_t& utf8_bytes_index,
6316 size_t& utf8_bytes_filled)
6318 utf8_bytes_index = 0;
6322 utf8_bytes[0] = std::char_traits<char>::eof();
6323 utf8_bytes_filled = 1;
6328 const auto wc = input.get_character();
6333 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6334 utf8_bytes_filled = 1;
6336 else if (wc <= 0x7FF)
6338 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6339 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6340 utf8_bytes_filled = 2;
6342 else if (0xD800 > wc || wc >= 0xE000)
6344 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6345 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6346 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6347 utf8_bytes_filled = 3;
6353 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6354 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6355 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6356 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6357 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6358 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6359 utf8_bytes_filled = 4;
6363 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6364 utf8_bytes_filled = 1;
6372 template<
typename BaseInputAdapter,
typename W
ideCharType>
6379 : base_adapter(base) {}
6384 if (utf8_bytes_index == utf8_bytes_filled)
6386 fill_buffer<sizeof(WideCharType)>();
6394 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
6395 return utf8_bytes[utf8_bytes_index++];
6399 BaseInputAdapter base_adapter;
6408 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = { {0, 0, 0, 0} };
6411 std::size_t utf8_bytes_index = 0;
6413 std::size_t utf8_bytes_filled = 0;
6417 template<
typename IteratorType,
typename Enable =
void>
6421 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6426 return adapter_type(std::move(first), std::move(last));
6430 template<
typename T>
6440 template<
typename IteratorType>
6444 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6455 template<
typename IteratorType>
6459 return factory_type::create(first, last);
6466 namespace container_input_adapter_factory_impl
6472 template<
typename ContainerType,
typename Enable =
void>
6475 template<
typename ContainerType>
6477 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6489 template<
typename ContainerType>
6516 template <
typename CharT,
6517 typename std::enable_if <
6518 std::is_pointer<CharT>::value &&
6519 !std::is_array<CharT>::value&&
6520 std::is_integral<typename std::remove_pointer<CharT>::type>
::value &&
6521 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6525 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
6526 const auto* ptr =
reinterpret_cast<const char*
>(b);
6530 template<
typename T, std::
size_t N>
6542 template <
typename CharT,
6543 typename std::enable_if <
6544 std::is_pointer<CharT>::value&&
6545 std::is_integral<typename std::remove_pointer<CharT>::type>
::value &&
6546 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6549 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
6551 template<
class IteratorType,
6552 typename std::enable_if<
6553 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
6560 return std::move(ia);
6603template<
typename BasicJsonType>
6707 const std::string& last_token,
6734 template<
typename BasicJsonType>
6750 : root(r), allow_exceptions(allow_exceptions_)
6762 handle_value(
nullptr);
6798 handle_value(std::move(val));
6804 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6806 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6808 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
6820 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
6829 ref_stack.back()->set_parents();
6830 ref_stack.pop_back();
6836 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6838 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6840 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
6851 ref_stack.back()->set_parents();
6852 ref_stack.pop_back();
6856 template<
class Exception>
6858 const Exception& ex)
6861 static_cast<void>(ex);
6862 if (allow_exceptions)
6881 template<
typename Value>
6883 BasicJsonType* handle_value(Value&& v)
6885 if (ref_stack.empty())
6887 root = BasicJsonType(std::forward<Value>(v));
6891 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6893 if (ref_stack.back()->is_array())
6895 ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v));
6896 return &(ref_stack.back()->m_data.m_value.array->back());
6901 *object_element = BasicJsonType(std::forward<Value>(v));
6902 return object_element;
6906 BasicJsonType& root;
6908 std::vector<BasicJsonType*> ref_stack{};
6910 BasicJsonType* object_element =
nullptr;
6912 bool errored =
false;
6914 const bool allow_exceptions =
true;
6917 template<
typename BasicJsonType>
6931 const bool allow_exceptions_ =
true)
6932 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6934 keep_stack.push_back(
true);
6946 handle_value(
nullptr);
6982 handle_value(std::move(val));
6989 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
6990 keep_stack.push_back(keep);
6992 auto val = handle_value(BasicJsonType::value_t::object,
true);
6993 ref_stack.push_back(val.second);
6996 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6998 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
7006 BasicJsonType k = BasicJsonType(val);
7009 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
7010 key_keep_stack.push_back(keep);
7013 if (keep && ref_stack.back())
7015 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) =
discarded);
7023 if (ref_stack.back())
7025 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
7032 ref_stack.back()->set_parents();
7038 ref_stack.pop_back();
7039 keep_stack.pop_back();
7041 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
7044 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
7046 if (it->is_discarded())
7048 ref_stack.back()->erase(it);
7059 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
7060 keep_stack.push_back(keep);
7062 auto val = handle_value(BasicJsonType::value_t::array,
true);
7063 ref_stack.push_back(val.second);
7066 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
7068 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
7078 if (ref_stack.back())
7080 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
7083 ref_stack.back()->set_parents();
7094 ref_stack.pop_back();
7095 keep_stack.pop_back();
7098 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
7100 ref_stack.back()->m_data.m_value.array->pop_back();
7106 template<
class Exception>
7108 const Exception& ex)
7111 static_cast<void>(ex);
7112 if (allow_exceptions)
7140 template<
typename Value>
7141 std::pair<bool, BasicJsonType*> handle_value(Value&& v,
const bool skip_callback =
false)
7147 if (!keep_stack.back())
7149 return {
false,
nullptr };
7153 auto value = BasicJsonType(std::forward<Value>(v));
7156 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value, value);
7161 return {
false,
nullptr };
7164 if (ref_stack.empty())
7166 root = std::move(value);
7167 return {
true, &root };
7172 if (!ref_stack.back())
7174 return {
false,
nullptr };
7178 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
7181 if (ref_stack.back()->is_array())
7183 ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
7184 return {
true, &(ref_stack.back()->m_data.m_value.array->back()) };
7191 const bool store_element = key_keep_stack.back();
7192 key_keep_stack.pop_back();
7196 return {
false,
nullptr };
7200 *object_element = std::move(value);
7201 return {
true, object_element };
7205 BasicJsonType& root;
7207 std::vector<BasicJsonType*> ref_stack{};
7209 std::vector<bool> keep_stack{};
7211 std::vector<bool> key_keep_stack{};
7213 BasicJsonType* object_element =
nullptr;
7215 bool errored =
false;
7219 const bool allow_exceptions =
true;
7221 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
7224 template<
typename BasicJsonType>
7319#include <initializer_list>
7339 template<
typename BasicJsonType>
7372 case token_type::uninitialized:
7373 return "<uninitialized>";
7374 case token_type::literal_true:
7375 return "true literal";
7376 case token_type::literal_false:
7377 return "false literal";
7378 case token_type::literal_null:
7379 return "null literal";
7380 case token_type::value_string:
7381 return "string literal";
7382 case token_type::value_unsigned:
7383 case token_type::value_integer:
7384 case token_type::value_float:
7385 return "number literal";
7386 case token_type::begin_array:
7388 case token_type::begin_object:
7390 case token_type::end_array:
7392 case token_type::end_object:
7394 case token_type::name_separator:
7396 case token_type::value_separator:
7398 case token_type::parse_error:
7399 return "<parse error>";
7400 case token_type::end_of_input:
7401 return "end of input";
7402 case token_type::literal_or_value:
7403 return "'[', '{', or a literal";
7406 return "unknown token";
7416 template<
typename BasicJsonType,
typename InputAdapterType>
7419 using number_integer_t =
typename BasicJsonType::number_integer_t;
7420 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
7421 using number_float_t =
typename BasicJsonType::number_float_t;
7422 using string_t =
typename BasicJsonType::string_t;
7423 using char_type =
typename InputAdapterType::char_type;
7424 using char_int_type =
typename std::char_traits<char_type>::int_type;
7429 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7430 : ia(
std::move(adapter))
7431 , ignore_comments(ignore_comments_)
7432 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
7449 static char get_decimal_point() noexcept
7451 const auto* loc = localeconv();
7453 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7481 const auto factors = { 12u, 8u, 4u, 0u };
7482 for (
const auto factor : factors)
7486 if (current >=
'0' && current <=
'9')
7488 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7490 else if (current >=
'A' && current <=
'F')
7492 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7494 else if (current >=
'a' && current <=
'f')
7496 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7504 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7523 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
7525 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7528 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7537 error_message =
"invalid string: ill-formed UTF-8 byte";
7560 token_type scan_string()
7574 case std::char_traits<char_type>::eof():
7576 error_message =
"invalid string: missing closing quote";
7577 return token_type::parse_error;
7583 return token_type::value_string;
7627 const int codepoint1 = get_codepoint();
7628 int codepoint = codepoint1;
7632 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7633 return token_type::parse_error;
7637 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7642 const int codepoint2 = get_codepoint();
7646 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7647 return token_type::parse_error;
7654 codepoint =
static_cast<int>(
7656 (
static_cast<unsigned int>(codepoint1) << 10u)
7658 +
static_cast<unsigned int>(codepoint2)
7666 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7667 return token_type::parse_error;
7672 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7673 return token_type::parse_error;
7680 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7681 return token_type::parse_error;
7686 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7689 if (codepoint < 0x80)
7692 add(
static_cast<char_int_type
>(codepoint));
7694 else if (codepoint <= 0x7FF)
7697 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7698 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7700 else if (codepoint <= 0xFFFF)
7703 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7704 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7705 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7710 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7711 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7712 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7713 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7721 error_message =
"invalid string: forbidden character after backslash";
7722 return token_type::parse_error;
7731 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7732 return token_type::parse_error;
7737 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7738 return token_type::parse_error;
7743 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7744 return token_type::parse_error;
7749 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7750 return token_type::parse_error;
7755 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7756 return token_type::parse_error;
7761 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7762 return token_type::parse_error;
7767 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7768 return token_type::parse_error;
7773 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7774 return token_type::parse_error;
7779 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7780 return token_type::parse_error;
7785 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7786 return token_type::parse_error;
7791 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7792 return token_type::parse_error;
7797 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7798 return token_type::parse_error;
7803 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7804 return token_type::parse_error;
7809 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7810 return token_type::parse_error;
7815 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7816 return token_type::parse_error;
7821 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7822 return token_type::parse_error;
7827 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7828 return token_type::parse_error;
7833 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7834 return token_type::parse_error;
7839 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7840 return token_type::parse_error;
7845 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7846 return token_type::parse_error;
7851 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7852 return token_type::parse_error;
7857 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7858 return token_type::parse_error;
7863 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7864 return token_type::parse_error;
7869 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7870 return token_type::parse_error;
7875 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7876 return token_type::parse_error;
7881 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7882 return token_type::parse_error;
7887 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7888 return token_type::parse_error;
7893 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7894 return token_type::parse_error;
7899 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7900 return token_type::parse_error;
7905 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7906 return token_type::parse_error;
7911 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7912 return token_type::parse_error;
7917 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7918 return token_type::parse_error;
8055 return token_type::parse_error;
8065 return token_type::parse_error;
8089 return token_type::parse_error;
8099 return token_type::parse_error;
8109 return token_type::parse_error;
8121 return token_type::parse_error;
8131 return token_type::parse_error;
8139 error_message =
"invalid string: ill-formed UTF-8 byte";
8140 return token_type::parse_error;
8163 case std::char_traits<char_type>::eof():
8180 case std::char_traits<char_type>::eof():
8183 error_message =
"invalid comment; missing closing '*/'";
8211 error_message =
"invalid comment; expecting '/' or '*' after '/'";
8218 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
8220 f = std::strtof(str, endptr);
8224 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
8226 f = std::strtod(str, endptr);
8230 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
8232 f = std::strtold(str, endptr);
8275 token_type scan_number()
8282 token_type number_type = token_type::value_unsigned;
8290 goto scan_number_minus;
8296 goto scan_number_zero;
8310 goto scan_number_any1;
8320 number_type = token_type::value_integer;
8326 goto scan_number_zero;
8340 goto scan_number_any1;
8345 error_message =
"invalid number; expected digit after '-'";
8346 return token_type::parse_error;
8356 add(decimal_point_char);
8357 goto scan_number_decimal1;
8364 goto scan_number_exponent;
8368 goto scan_number_done;
8387 goto scan_number_any1;
8392 add(decimal_point_char);
8393 goto scan_number_decimal1;
8400 goto scan_number_exponent;
8404 goto scan_number_done;
8407 scan_number_decimal1:
8409 number_type = token_type::value_float;
8424 goto scan_number_decimal2;
8429 error_message =
"invalid number; expected digit after '.'";
8430 return token_type::parse_error;
8434 scan_number_decimal2:
8450 goto scan_number_decimal2;
8457 goto scan_number_exponent;
8461 goto scan_number_done;
8464 scan_number_exponent:
8466 number_type = token_type::value_float;
8473 goto scan_number_sign;
8488 goto scan_number_any2;
8494 "invalid number; expected '+', '-', or digit after exponent";
8495 return token_type::parse_error;
8515 goto scan_number_any2;
8520 error_message =
"invalid number; expected digit after exponent sign";
8521 return token_type::parse_error;
8541 goto scan_number_any2;
8545 goto scan_number_done;
8553 char* endptr =
nullptr;
8557 if (number_type == token_type::value_unsigned)
8559 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8562 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8566 value_unsigned =
static_cast<number_unsigned_t
>(x);
8567 if (value_unsigned == x)
8569 return token_type::value_unsigned;
8573 else if (number_type == token_type::value_integer)
8575 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8578 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8582 value_integer =
static_cast<number_integer_t
>(x);
8583 if (value_integer == x)
8585 return token_type::value_integer;
8592 strtof(value_float, token_buffer.data(), &endptr);
8595 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8597 return token_type::value_float;
8606 token_type scan_literal(const char_type* literal_text, const
std::
size_t length,
8607 token_type return_type)
8609 JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
8610 for (std::size_t i = 1; i < length; ++i)
8614 error_message =
"invalid literal";
8615 return token_type::parse_error;
8626 void reset() noexcept
8628 token_buffer.clear();
8629 token_string.clear();
8630 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8645 ++position.chars_read_total;
8646 ++position.chars_read_current_line;
8655 current = ia.get_character();
8660 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8663 if (current ==
'\n')
8665 ++position.lines_read;
8666 position.chars_read_current_line = 0;
8684 --position.chars_read_total;
8687 if (position.chars_read_current_line == 0)
8689 if (position.lines_read > 0)
8691 --position.lines_read;
8696 --position.chars_read_current_line;
8702 token_string.pop_back();
8707 void add(char_int_type c)
8709 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8720 return value_integer;
8726 return value_unsigned;
8738 return token_buffer;
8758 for (
const auto c : token_string)
8760 if (
static_cast<unsigned char>(c) <=
'\x1F')
8763 std::array<char, 9> cs{ {} };
8764 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8765 result += cs.data();
8770 result.push_back(
static_cast<std::string::value_type
>(c));
8781 return error_message;
8797 return get() == 0xBB &&
get() == 0xBF;
8811 }
while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8817 if (position.chars_read_total == 0 && !skip_bom())
8819 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8820 return token_type::parse_error;
8827 while (ignore_comments && current ==
'/')
8829 if (!scan_comment())
8831 return token_type::parse_error;
8842 return token_type::begin_array;
8844 return token_type::end_array;
8846 return token_type::begin_object;
8848 return token_type::end_object;
8850 return token_type::name_separator;
8852 return token_type::value_separator;
8857 std::array<char_type, 4> true_literal = { {
static_cast<char_type
>(
't'),
static_cast<char_type
>(
'r'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'e')} };
8858 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8862 std::array<char_type, 5> false_literal = { {
static_cast<char_type
>(
'f'),
static_cast<char_type
>(
'a'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
's'),
static_cast<char_type
>(
'e')} };
8863 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8867 std::array<char_type, 4> null_literal = { {
static_cast<char_type
>(
'n'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
'l')} };
8868 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8873 return scan_string();
8887 return scan_number();
8892 case std::char_traits<char_type>::eof():
8893 return token_type::end_of_input;
8897 error_message =
"invalid literal";
8898 return token_type::parse_error;
8904 InputAdapterType ia;
8907 const bool ignore_comments =
false;
8910 char_int_type current = std::char_traits<char_type>::eof();
8913 bool next_unget =
false;
8919 std::vector<char_type> token_string{};
8922 string_t token_buffer{};
8925 const char* error_message =
"";
8928 number_integer_t value_integer = 0;
8929 number_unsigned_t value_unsigned = 0;
8930 number_float_t value_float = 0;
8933 const char_int_type decimal_point_char =
'.';
8967 template<
typename T>
8970 template<
typename T>
8972 decltype(std::declval<T&>().boolean(std::declval<bool>()));
8974 template<
typename T,
typename Integer>
8976 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
8978 template<
typename T,
typename Un
signed>
8980 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
8982 template<
typename T,
typename Float,
typename String>
8984 std::declval<Float>(), std::declval<const String&>()));
8986 template<
typename T,
typename String>
8988 decltype(std::declval<T&>().string(std::declval<String&>()));
8990 template<
typename T,
typename Binary>
8992 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
8994 template<
typename T>
8996 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8998 template<
typename T,
typename String>
9000 decltype(std::declval<T&>().key(std::declval<String&>()));
9002 template<
typename T>
9005 template<
typename T>
9007 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
9009 template<
typename T>
9012 template<
typename T,
typename Exception>
9014 std::declval<std::size_t>(), std::declval<const std::string&>(),
9015 std::declval<const Exception&>()));
9017 template<
typename SAX,
typename BasicJsonType>
9022 "BasicJsonType must be of type basic_json<...>");
9024 using number_integer_t =
typename BasicJsonType::number_integer_t;
9025 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9026 using number_float_t =
typename BasicJsonType::number_float_t;
9027 using string_t =
typename BasicJsonType::string_t;
9028 using binary_t =
typename BasicJsonType::binary_t;
9029 using exception_t =
typename BasicJsonType::exception;
9048 template<
typename SAX,
typename BasicJsonType>
9053 "BasicJsonType must be of type basic_json<...>");
9055 using number_integer_t =
typename BasicJsonType::number_integer_t;
9056 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9057 using number_float_t =
typename BasicJsonType::number_float_t;
9058 using string_t =
typename BasicJsonType::string_t;
9059 using binary_t =
typename BasicJsonType::binary_t;
9060 using exception_t =
typename BasicJsonType::exception;
9064 "Missing/invalid function: bool null()");
9066 "Missing/invalid function: bool boolean(bool)");
9068 "Missing/invalid function: bool boolean(bool)");
9072 "Missing/invalid function: bool number_integer(number_integer_t)");
9076 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9078 number_float_t, string_t>
::value,
9079 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9082 "Missing/invalid function: bool string(string_t&)");
9085 "Missing/invalid function: bool binary(binary_t&)");
9087 "Missing/invalid function: bool start_object(std::size_t)");
9089 "Missing/invalid function: bool key(string_t&)");
9091 "Missing/invalid function: bool end_object()");
9093 "Missing/invalid function: bool start_array(std::size_t)");
9095 "Missing/invalid function: bool end_array()");
9098 "Missing/invalid function: bool parse_error(std::size_t, const "
9099 "std::string&, const exception&)");
9131 static inline bool little_endianness(
int num = 1) noexcept
9133 return *
reinterpret_cast<char*
>(&num) == 1;
9144 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
9147 using number_integer_t =
typename BasicJsonType::number_integer_t;
9148 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9149 using number_float_t =
typename BasicJsonType::number_float_t;
9150 using string_t =
typename BasicJsonType::string_t;
9151 using binary_t =
typename BasicJsonType::binary_t;
9152 using json_sax_t = SAX;
9153 using char_type =
typename InputAdapterType::char_type;
9154 using char_int_type =
typename std::char_traits<char_type>::int_type;
9185 const
bool strict = true,
9189 bool result =
false;
9194 result = parse_bson_internal();
9198 result = parse_cbor_internal(
true, tag_handler);
9202 result = parse_msgpack_internal();
9207 result = parse_ubjson_internal();
9229 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read,
9230 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9246 bool parse_bson_internal()
9248 std::int32_t document_size{};
9261 return sax->end_object();
9271 bool get_bson_cstr(string_t& result)
9273 auto out = std::back_inserter(result);
9281 if (current == 0x00)
9285 *out++ =
static_cast<typename string_t::value_type
>(current);
9300 template<
typename NumberType>
9301 bool get_bson_string(
const NumberType len, string_t& result)
9305 auto last_token = get_token_string();
9307 exception_message(
input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(len)),
"string"),
nullptr));
9310 return get_string(
input_format_t::bson, len -
static_cast<NumberType
>(1), result) && get() != std::char_traits<char_type>::eof();
9322 template<
typename NumberType>
9323 bool get_bson_binary(
const NumberType len, binary_t& result)
9327 auto last_token = get_token_string();
9329 exception_message(
input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(len)),
"binary"),
nullptr));
9333 std::uint8_t subtype{};
9335 result.set_subtype(subtype);
9350 bool parse_bson_element_internal(
const char_int_type element_type,
9351 const std::size_t element_type_parse_position)
9353 switch (element_type)
9358 return get_number<double, true>(
input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9370 return parse_bson_internal();
9375 return parse_bson_array();
9387 return sax->boolean(get() != 0);
9397 std::int32_t
value{};
9403 std::int64_t
value{};
9409 std::array<char, 3> cr{ {} };
9410 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
9411 const std::string cr_str{ cr.data() };
9412 return sax->parse_error(element_type_parse_position, cr_str,
9430 bool parse_bson_element_list(
const bool is_array)
9434 while (
auto element_type = get())
9441 const std::size_t element_type_parse_position = chars_read;
9447 if (!is_array && !sax->key(
key))
9452 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
9468 bool parse_bson_array()
9470 std::int32_t document_size{};
9483 return sax->end_array();
9498 bool parse_cbor_internal(
const bool get_char,
9501 switch (get_char ? get() : current)
9504 case std::char_traits<char_type>::eof():
9532 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
9536 std::uint8_t number{};
9542 std::uint16_t number{};
9548 std::uint32_t number{};
9554 std::uint64_t number{};
9583 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
9587 std::uint8_t number{};
9588 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9593 std::uint16_t number{};
9594 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9599 std::uint32_t number{};
9600 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9605 std::uint64_t number{};
9606 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
9607 -
static_cast<number_integer_t
>(number));
9642 return get_cbor_binary(b) && sax->binary(b);
9677 return get_cbor_string(s) && sax->string(s);
9705 return get_cbor_array(
9706 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9711 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9716 std::uint16_t len{};
9717 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9722 std::uint32_t len{};
9723 return get_number(
input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9728 std::uint64_t len{};
9729 return get_number(
input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9733 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
9760 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9765 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9770 std::uint16_t len{};
9771 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9776 std::uint32_t len{};
9777 return get_number(
input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9782 std::uint64_t len{};
9783 return get_number(
input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9787 return get_cbor_object(
static_cast<std::size_t
>(-1), tag_handler);
9809 switch (tag_handler)
9813 auto last_token = get_token_string();
9825 std::uint8_t subtype_to_ignore{};
9831 std::uint16_t subtype_to_ignore{};
9837 std::uint32_t subtype_to_ignore{};
9843 std::uint64_t subtype_to_ignore{};
9850 return parse_cbor_internal(
true, tag_handler);
9861 std::uint8_t subtype{};
9863 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9868 std::uint16_t subtype{};
9870 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9875 std::uint32_t subtype{};
9877 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9882 std::uint64_t subtype{};
9884 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9888 return parse_cbor_internal(
true, tag_handler);
9891 return get_cbor_binary(b) && sax->binary(b);
9901 return sax->boolean(
false);
9904 return sax->boolean(
true);
9911 const auto byte1_raw = get();
9916 const auto byte2_raw = get();
9922 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9923 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9933 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
9934 const double val = [&half]
9936 const int exp = (half >> 10u) & 0x1Fu;
9937 const unsigned int mant = half & 0x3FFu;
9943 return std::ldexp(mant, -24);
9946 ? std::numeric_limits<double>::infinity()
9947 :
std::numeric_limits<double>::quiet_NaN();
9949 return std::ldexp(mant + 1024, exp - 25);
9952 return sax->number_float((half & 0x8000u) != 0
9953 ?
static_cast<number_float_t
>(-val)
9954 :
static_cast<number_float_t
>(val),
"");
9960 return get_number(
input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9966 return get_number(
input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9971 auto last_token = get_token_string();
9989 bool get_cbor_string(string_t& result)
10029 std::uint8_t len{};
10035 std::uint16_t len{};
10041 std::uint32_t len{};
10047 std::uint64_t len{};
10053 while (get() != 0xFF)
10056 if (!get_cbor_string(chunk))
10060 result.append(chunk);
10067 auto last_token = get_token_string();
10069 exception_message(
input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10085 bool get_cbor_binary(binary_t& result)
10125 std::uint8_t len{};
10132 std::uint16_t len{};
10139 std::uint32_t len{};
10146 std::uint64_t len{};
10153 while (get() != 0xFF)
10156 if (!get_cbor_binary(chunk))
10160 result.insert(result.end(), chunk.begin(), chunk.end());
10167 auto last_token = get_token_string();
10169 exception_message(
input_format_t::cbor,
concat(
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token),
"binary"),
nullptr));
10180 bool get_cbor_array(
const std::size_t len,
10188 if (len !=
static_cast<std::size_t
>(-1))
10190 for (std::size_t i = 0; i < len; ++i)
10200 while (get() != 0xFF)
10209 return sax->end_array();
10218 bool get_cbor_object(
const std::size_t len,
10229 if (len !=
static_cast<std::size_t
>(-1))
10231 for (std::size_t i = 0; i < len; ++i)
10248 while (get() != 0xFF)
10264 return sax->end_object();
10274 bool parse_msgpack_internal()
10279 case std::char_traits<char_type>::eof():
10411 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
10430 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10449 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10489 return get_msgpack_string(s) && sax->string(s);
10493 return sax->null();
10496 return sax->boolean(
false);
10499 return sax->boolean(
true);
10514 return get_msgpack_binary(b) && sax->binary(b);
10520 return get_number(
input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10526 return get_number(
input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10531 std::uint8_t number{};
10537 std::uint16_t number{};
10543 std::uint32_t number{};
10549 std::uint64_t number{};
10555 std::int8_t number{};
10561 std::int16_t number{};
10567 std::int32_t number{};
10573 std::int64_t number{};
10579 std::uint16_t len{};
10585 std::uint32_t len{};
10586 return get_number(
input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
10591 std::uint16_t len{};
10597 std::uint32_t len{};
10598 return get_number(
input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
10634 return sax->number_integer(
static_cast<std::int8_t
>(current));
10638 auto last_token = get_token_string();
10655 bool get_msgpack_string(string_t& result)
10703 std::uint8_t len{};
10709 std::uint16_t len{};
10715 std::uint32_t len{};
10721 auto last_token = get_token_string();
10723 exception_message(
input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10738 bool get_msgpack_binary(binary_t& result)
10741 auto assign_and_return_true = [&result](std::int8_t subtype)
10743 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
10751 std::uint8_t len{};
10758 std::uint16_t len{};
10765 std::uint32_t len{};
10772 std::uint8_t len{};
10773 std::int8_t subtype{};
10777 assign_and_return_true(subtype);
10782 std::uint16_t len{};
10783 std::int8_t subtype{};
10787 assign_and_return_true(subtype);
10792 std::uint32_t len{};
10793 std::int8_t subtype{};
10797 assign_and_return_true(subtype);
10802 std::int8_t subtype{};
10805 assign_and_return_true(subtype);
10810 std::int8_t subtype{};
10813 assign_and_return_true(subtype);
10818 std::int8_t subtype{};
10821 assign_and_return_true(subtype);
10826 std::int8_t subtype{};
10829 assign_and_return_true(subtype);
10834 std::int8_t subtype{};
10837 assign_and_return_true(subtype);
10849 bool get_msgpack_array(
const std::size_t len)
10856 for (std::size_t i = 0; i < len; ++i)
10864 return sax->end_array();
10871 bool get_msgpack_object(
const std::size_t len)
10879 for (std::size_t i = 0; i < len; ++i)
10894 return sax->end_object();
10908 bool parse_ubjson_internal(
const bool get_char =
true)
10910 return get_ubjson_value(get_char ? get_ignore_noop() : current);
10927 bool get_ubjson_string(string_t& result,
const bool get_char =
true)
10943 std::uint8_t len{};
10944 return get_number(input_format, len) && get_string(input_format, len, result);
10950 return get_number(input_format, len) && get_string(input_format, len, result);
10955 std::int16_t len{};
10956 return get_number(input_format, len) && get_string(input_format, len, result);
10961 std::int32_t len{};
10962 return get_number(input_format, len) && get_string(input_format, len, result);
10967 std::int64_t len{};
10968 return get_number(input_format, len) && get_string(input_format, len, result);
10977 std::uint16_t len{};
10978 return get_number(input_format, len) && get_string(input_format, len, result);
10987 std::uint32_t len{};
10988 return get_number(input_format, len) && get_string(input_format, len, result);
10997 std::uint64_t len{};
10998 return get_number(input_format, len) && get_string(input_format, len, result);
11004 auto last_token = get_token_string();
11005 std::string message;
11009 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11013 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11015 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11022 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
11024 std::pair<std::size_t, char_int_type> size_and_type;
11026 bool no_ndarray =
true;
11033 if (size_and_type.first != npos)
11035 if (size_and_type.second != 0)
11037 if (size_and_type.second !=
'N')
11039 for (std::size_t i = 0; i < size_and_type.first; ++i)
11045 dim.push_back(dimlen);
11051 for (std::size_t i = 0; i < size_and_type.first; ++i)
11057 dim.push_back(dimlen);
11063 while (current !=
']')
11069 dim.push_back(dimlen);
11087 bool get_ubjson_size_value(std::size_t& result,
bool& is_ndarray, char_int_type prefix = 0)
11091 prefix = get_ignore_noop();
11098 std::uint8_t number{};
11103 result =
static_cast<std::size_t
>(number);
11109 std::int8_t number{};
11116 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11117 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11119 result =
static_cast<std::size_t
>(number);
11125 std::int16_t number{};
11132 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11133 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11135 result =
static_cast<std::size_t
>(number);
11141 std::int32_t number{};
11148 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11149 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11151 result =
static_cast<std::size_t
>(number);
11157 std::int64_t number{};
11164 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11165 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11167 if (!value_in_range_of<std::size_t>(number))
11170 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11172 result =
static_cast<std::size_t
>(number);
11182 std::uint16_t number{};
11187 result =
static_cast<std::size_t
>(number);
11197 std::uint32_t number{};
11202 result = conditional_static_cast<std::size_t>(number);
11212 std::uint64_t number{};
11217 if (!value_in_range_of<std::size_t>(number))
11220 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11222 result = detail::conditional_static_cast<std::size_t>(number);
11234 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimensional vector is not allowed",
"size"),
nullptr));
11236 std::vector<size_t> dim;
11241 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11243 result = dim.at(dim.size() - 1);
11257 string_t
key =
"_ArraySize_";
11266 if (result == 0 || result == npos)
11268 return sax->parse_error(chars_read, get_token_string(),
out_of_range::create(408, exception_message(input_format,
"excessive ndarray size caused overflow",
"size"),
nullptr));
11276 return sax->end_array();
11285 auto last_token = get_token_string();
11286 std::string message;
11290 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
11294 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
11296 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
11310 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result,
bool inside_ndarray =
false)
11312 result.first = npos;
11314 bool is_ndarray =
false;
11318 if (current ==
'$')
11320 result.second = get();
11322 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
11324 auto last_token = get_token_string();
11326 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
11341 auto last_token = get_token_string();
11343 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
11346 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11349 if (inside_ndarray)
11351 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
11352 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
11354 result.second |= (1 << 8);
11359 if (current ==
'#')
11361 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11364 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
11365 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
11377 bool get_ubjson_value(
const char_int_type prefix)
11381 case std::char_traits<char_type>::eof():
11382 return unexpect_eof(input_format,
"value");
11385 return sax->boolean(
true);
11387 return sax->boolean(
false);
11390 return sax->null();
11394 std::uint8_t number{};
11395 return get_number(input_format, number) && sax->number_unsigned(number);
11400 std::int8_t number{};
11401 return get_number(input_format, number) && sax->number_integer(number);
11406 std::int16_t number{};
11407 return get_number(input_format, number) && sax->number_integer(number);
11412 std::int32_t number{};
11413 return get_number(input_format, number) && sax->number_integer(number);
11418 std::int64_t number{};
11419 return get_number(input_format, number) && sax->number_integer(number);
11428 std::uint16_t number{};
11429 return get_number(input_format, number) && sax->number_unsigned(number);
11438 std::uint32_t number{};
11439 return get_number(input_format, number) && sax->number_unsigned(number);
11448 std::uint64_t number{};
11449 return get_number(input_format, number) && sax->number_unsigned(number);
11458 const auto byte1_raw = get();
11463 const auto byte2_raw = get();
11469 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
11470 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
11480 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
11481 const double val = [&half]
11483 const int exp = (half >> 10u) & 0x1Fu;
11484 const unsigned int mant = half & 0x3FFu;
11490 return std::ldexp(mant, -24);
11493 ? std::numeric_limits<double>::infinity()
11494 :
std::numeric_limits<double>::quiet_NaN();
11496 return std::ldexp(mant + 1024, exp - 25);
11499 return sax->number_float((half & 0x8000u) != 0
11500 ?
static_cast<number_float_t
>(-val)
11501 :
static_cast<number_float_t
>(val),
"");
11507 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11513 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11518 return get_ubjson_high_precision_number();
11530 auto last_token = get_token_string();
11532 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
11534 string_t s(1,
static_cast<typename string_t::value_type
>(current));
11535 return sax->string(s);
11541 return get_ubjson_string(s) && sax->string(s);
11545 return get_ubjson_array();
11548 return get_ubjson_object();
11553 auto last_token = get_token_string();
11554 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format,
"invalid byte: 0x" + last_token,
"value"),
nullptr));
11560 bool get_ubjson_array()
11562 std::pair<std::size_t, char_int_type> size_and_type;
11571 if (input_format ==
input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11573 size_and_type.second &= ~(
static_cast<char_int_type
>(1) << 8);
11574 auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](
const bjd_type& p, char_int_type t)
11576 return p.first < t;
11578 string_t
key =
"_ArrayType_";
11581 auto last_token = get_token_string();
11583 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
11586 string_t type = it->second;
11592 if (size_and_type.second ==
'C')
11594 size_and_type.second =
'U';
11597 key =
"_ArrayData_";
11603 for (std::size_t i = 0; i < size_and_type.first; ++i)
11611 return (sax->end_array() && sax->end_object());
11614 if (size_and_type.first != npos)
11621 if (size_and_type.second != 0)
11623 if (size_and_type.second !=
'N')
11625 for (std::size_t i = 0; i < size_and_type.first; ++i)
11636 for (std::size_t i = 0; i < size_and_type.first; ++i)
11652 while (current !=
']')
11662 return sax->end_array();
11668 bool get_ubjson_object()
11670 std::pair<std::size_t, char_int_type> size_and_type;
11677 if (input_format ==
input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11679 auto last_token = get_token_string();
11681 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
11685 if (size_and_type.first != npos)
11692 if (size_and_type.second != 0)
11694 for (std::size_t i = 0; i < size_and_type.first; ++i)
11709 for (std::size_t i = 0; i < size_and_type.first; ++i)
11730 while (current !=
'}')
11745 return sax->end_object();
11751 bool get_ubjson_high_precision_number()
11754 std::size_t size{};
11755 bool no_ndarray =
true;
11756 auto res = get_ubjson_size_value(size, no_ndarray);
11763 std::vector<char> number_vector;
11764 for (std::size_t i = 0; i < size; ++i)
11771 number_vector.push_back(
static_cast<char>(current));
11777 const auto result_number = number_lexer.scan();
11778 const auto number_string = number_lexer.get_token_string();
11779 const auto result_remainder = number_lexer.scan();
11786 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11789 switch (result_number)
11791 case token_type::value_integer:
11792 return sax->number_integer(number_lexer.get_number_integer());
11793 case token_type::value_unsigned:
11794 return sax->number_unsigned(number_lexer.get_number_unsigned());
11795 case token_type::value_float:
11796 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
11797 case token_type::uninitialized:
11798 case token_type::literal_true:
11799 case token_type::literal_false:
11800 case token_type::literal_null:
11801 case token_type::value_string:
11802 case token_type::begin_array:
11803 case token_type::begin_object:
11804 case token_type::end_array:
11805 case token_type::end_object:
11806 case token_type::name_separator:
11807 case token_type::value_separator:
11808 case token_type::parse_error:
11809 case token_type::end_of_input:
11810 case token_type::literal_or_value:
11813 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11830 char_int_type get()
11833 return current = ia.get_character();
11839 char_int_type get_ignore_noop()
11844 }
while (current ==
'N');
11864 template<
typename NumberType,
bool InputIsLittleEndian = false>
11865 bool get_number(
const input_format_t format, NumberType& result)
11868 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
11869 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
11880 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(current);
11884 vec[i] =
static_cast<std::uint8_t
>(current);
11889 std::memcpy(&result, vec.data(),
sizeof(NumberType));
11907 template<
typename NumberType>
11909 const NumberType len,
11912 bool success =
true;
11913 for (NumberType i = 0; i < len; i++)
11921 result.push_back(
static_cast<typename string_t::value_type
>(current));
11940 template<
typename NumberType>
11942 const NumberType len,
11945 bool success =
true;
11946 for (NumberType i = 0; i < len; i++)
11954 result.push_back(
static_cast<std::uint8_t
>(current));
11965 bool unexpect_eof(const
input_format_t format, const
char* context)
const
11969 return sax->parse_error(chars_read,
"<end of file>",
11970 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
11978 std::string get_token_string()
const
11980 std::array<char, 3> cr{ {} };
11981 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
11982 return std::string{ cr.data() };
11992 const std::string&
detail,
11993 const std::string& context)
const
11995 std::string error_msg =
"syntax error while parsing ";
12000 error_msg +=
"CBOR";
12004 error_msg +=
"MessagePack";
12008 error_msg +=
"UBJSON";
12012 error_msg +=
"BSON";
12016 error_msg +=
"BJData";
12031 InputAdapterType ia;
12034 char_int_type current = std::char_traits<char_type>::eof();
12037 std::size_t chars_read = 0;
12040 const bool is_little_endian = little_endianness();
12046 json_sax_t* sax =
nullptr;
12049#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12050 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
12052#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
12053 make_array<bjd_type>( \
12054 bjd_type{'C', "char"}, \
12055 bjd_type{'D', "double"}, \
12056 bjd_type{'I', "int16"}, \
12057 bjd_type{'L', "int64"}, \
12058 bjd_type{'M', "uint64"}, \
12059 bjd_type{'U', "uint8"}, \
12060 bjd_type{'d', "single"}, \
12061 bjd_type{'i', "int8"}, \
12062 bjd_type{'l', "int32"}, \
12063 bjd_type{'m', "uint32"}, \
12064 bjd_type{'u', "uint16"})
12072 using bjd_type = std::pair<char_int_type, string_t>;
12077#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
12078#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
12081#ifndef JSON_HAS_CPP_17
12082 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12083 constexpr std::size_t binary_reader<BasicJsonType, InputAdapterType, SAX>::npos;
12106#include <functional>
12151 template<
typename BasicJsonType>
12153 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
12160 template<
typename BasicJsonType,
typename InputAdapterType>
12163 using number_integer_t =
typename BasicJsonType::number_integer_t;
12164 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
12165 using number_float_t =
typename BasicJsonType::number_float_t;
12166 using string_t =
typename BasicJsonType::string_t;
12174 const bool allow_exceptions_ =
true,
12175 const bool skip_comments =
false)
12177 , m_lexer(
std::move(adapter), skip_comments)
12178 , allow_exceptions(allow_exceptions_)
12199 sax_parse_internal(&sdp);
12202 if (
strict && (get_token() != token_type::end_of_input))
12207 exception_message(token_type::end_of_input,
"value"),
nullptr));
12219 if (result.is_discarded())
12227 sax_parse_internal(&sdp);
12230 if (
strict && (get_token() != token_type::end_of_input))
12245 result.assert_invariant();
12260 template<
typename SAX>
12265 const bool result = sax_parse_internal(sax);
12268 if (result &&
strict && (get_token() != token_type::end_of_input))
12279 template<
typename SAX>
12281 bool sax_parse_internal(SAX* sax)
12285 std::vector<bool> states;
12287 bool skip_to_state_evaluation =
false;
12291 if (!skip_to_state_evaluation)
12294 switch (last_token)
12296 case token_type::begin_object:
12304 if (get_token() == token_type::end_object)
12334 states.push_back(
false);
12341 case token_type::begin_array:
12349 if (get_token() == token_type::end_array)
12359 states.push_back(
true);
12365 case token_type::value_float:
12384 case token_type::literal_false:
12393 case token_type::literal_null:
12402 case token_type::literal_true:
12411 case token_type::value_integer:
12420 case token_type::value_string:
12429 case token_type::value_unsigned:
12438 case token_type::parse_error:
12446 case token_type::uninitialized:
12447 case token_type::end_array:
12448 case token_type::end_object:
12449 case token_type::name_separator:
12450 case token_type::value_separator:
12451 case token_type::end_of_input:
12452 case token_type::literal_or_value:
12463 skip_to_state_evaluation =
false;
12467 if (states.empty())
12476 if (get_token() == token_type::value_separator)
12497 skip_to_state_evaluation =
true;
12509 if (get_token() == token_type::value_separator)
12551 skip_to_state_evaluation =
true;
12562 token_type get_token()
12564 return last_token = m_lexer.
scan();
12567 std::string exception_message(
const token_type expected,
const std::string& context)
12569 std::string error_msg =
"syntax error ";
12571 if (!context.empty())
12573 error_msg +=
concat(
"while parsing ", context,
' ');
12578 if (last_token == token_type::parse_error)
12588 if (expected != token_type::uninitialized)
12598 const parser_callback_t<BasicJsonType> callback =
nullptr;
12600 token_type last_token = token_type::uninitialized;
12604 const bool allow_exceptions =
true;
12656 using difference_type = std::ptrdiff_t;
12657 static constexpr difference_type begin_value = 0;
12658 static constexpr difference_type end_value = begin_value + 1;
12662 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
12673 m_it = begin_value;
12685 return m_it == begin_value;
12691 return m_it == end_value;
12696 return lhs.m_it == rhs.m_it;
12701 return lhs.m_it < rhs.m_it;
12706 auto result = *
this;
12713 return lhs.m_it - rhs.m_it;
12724 auto result = *
this;
12737 auto result = *
this;
12794#include <type_traits>
12816 template<
typename IteratorType>
class iteration_proxy;
12817 template<
typename IteratorType>
class iteration_proxy_value;
12835 template<
typename BasicJsonType>
12842 friend BasicJsonType;
12846 using object_t =
typename BasicJsonType::object_t;
12847 using array_t =
typename BasicJsonType::array_t;
12850 "iter_impl only accepts (const) basic_json");
12852 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
12853 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>
::value,
12854 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
12869 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
12870 typename BasicJsonType::const_pointer,
12871 typename BasicJsonType::pointer>::type;
12874 typename std::conditional<std::is_const<BasicJsonType>::value,
12875 typename BasicJsonType::const_reference,
12876 typename BasicJsonType::reference>::type;
12893 switch (m_object->m_data.m_type)
12940 : m_object(other.m_object),
m_it(other.m_it)
12951 if (&other !=
this)
12953 m_object = other.m_object;
12965 : m_object(other.m_object),
m_it(other.m_it)
12976 m_object = other.m_object;
12986 void set_begin() noexcept
12990 switch (m_object->m_data.m_type)
13034 switch (m_object->m_data.m_type)
13073 switch (m_object->m_data.m_type)
13117 switch (m_object->m_data.m_type)
13157 auto result = *
this;
13170 switch (m_object->m_data.m_type)
13208 auto result = *
this;
13221 switch (m_object->m_data.m_type)
13257 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
13268 switch (m_object->m_data.m_type)
13293 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
13313 switch (m_object->m_data.m_type)
13340 return !other.operator < (*this);
13369 switch (m_object->m_data.m_type)
13413 auto result = *
this;
13435 auto result = *
this;
13448 switch (m_object->m_data.m_type)
13477 switch (m_object->m_data.m_type)
13511 const typename object_t::key_type&
key()
const
13588 template<
typename Base>
13662 auto it = --this->base();
13669 auto it = --this->base();
13670 return it.operator * ();
13682#include <type_traits>
13705 std::is_same<T, void>::value,
13724#include <algorithm>
13752template<
typename RefStringType>
13762 template<
typename T>
13763 struct string_t_helper
13771 using type = StringType;
13776 using string_t =
typename string_t_helper<RefStringType>::type;
13781 : reference_tokens(split(s))
13788 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
13792 return detail::concat(a,
'/', detail::escape(b));
13818 reference_tokens.insert(reference_tokens.end(),
13819 ptr.reference_tokens.begin(),
13820 ptr.reference_tokens.end());
13836 return *
this /= std::to_string(array_idx);
13884 reference_tokens.pop_back();
13896 return reference_tokens.back();
13903 reference_tokens.push_back(token);
13910 reference_tokens.push_back(std::move(token));
13917 return reference_tokens.empty();
13931 template<
typename BasicJsonType>
13932 static typename BasicJsonType::size_type array_index(
const string_t& s)
13934 using size_type =
typename BasicJsonType::size_type;
13948 const char* p = s.c_str();
13949 char* p_end =
nullptr;
13951 const unsigned long long res = std::strtoull(p, &p_end, 10);
13961 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
13966 return static_cast<size_type
>(res);
13978 result.reference_tokens = { reference_tokens[0] };
13991 template<
typename BasicJsonType>
13992 BasicJsonType& get_and_create(BasicJsonType& j)
const
13998 for (
const auto& reference_token : reference_tokens)
14000 switch (result->type())
14004 if (reference_token ==
"0")
14007 result = &result->operator[](0);
14012 result = &result->operator[](reference_token);
14020 result = &result->operator[](reference_token);
14027 result = &result->operator[](array_index<BasicJsonType>(reference_token));
14071 template<
typename BasicJsonType>
14072 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
14074 for (
const auto& reference_token : reference_tokens)
14077 if (ptr->is_null())
14081 std::all_of(reference_token.begin(), reference_token.end(),
14082 [](
const unsigned char x)
14084 return std::isdigit(x);
14088 *ptr = (nums || reference_token ==
"-")
14093 switch (ptr->type())
14098 ptr = &ptr->operator[](reference_token);
14104 if (reference_token ==
"-")
14107 ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
14112 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14139 template<
typename BasicJsonType>
14140 BasicJsonType& get_checked(BasicJsonType* ptr)
const
14142 for (
const auto& reference_token : reference_tokens)
14144 switch (ptr->type())
14149 ptr = &ptr->at(reference_token);
14159 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
14160 ") is out of range"), ptr));
14164 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14197 template<
typename BasicJsonType>
14198 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
14200 for (
const auto& reference_token : reference_tokens)
14202 switch (ptr->type())
14207 ptr = &ptr->operator[](reference_token);
14220 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14246 template<
typename BasicJsonType>
14247 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
14249 for (
const auto& reference_token : reference_tokens)
14251 switch (ptr->type())
14256 ptr = &ptr->at(reference_token);
14266 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
14267 ") is out of range"), ptr));
14271 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14295 template<
typename BasicJsonType>
14296 bool contains(
const BasicJsonType* ptr)
const
14298 for (
const auto& reference_token : reference_tokens)
14300 switch (ptr->type())
14304 if (!ptr->contains(reference_token))
14310 ptr = &ptr->operator[](reference_token);
14321 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
14333 for (std::size_t i = 1; i < reference_token.size(); i++)
14343 const auto idx = array_index<BasicJsonType>(reference_token);
14344 if (idx >= ptr->size())
14350 ptr = &ptr->operator[](idx);
14384 static std::vector<string_t> split(
const string_t& reference_string)
14386 std::vector<string_t> result;
14389 if (reference_string.empty())
14405 std::size_t slash = reference_string.find_first_of(
'/', 1),
14412 start = (slash == string_t::npos) ? 0 : slash + 1,
14414 slash = reference_string.find_first_of(
'/', start))
14418 auto reference_token = reference_string.substr(start, slash - start);
14421 for (std::size_t pos = reference_token.find_first_of(
'~');
14422 pos != string_t::npos;
14423 pos = reference_token.find_first_of(
'~', pos + 1))
14429 (reference_token[pos + 1] !=
'0' &&
14430 reference_token[pos + 1] !=
'1')))
14437 detail::unescape(reference_token);
14438 result.push_back(reference_token);
14452 template<
typename BasicJsonType>
14453 static void flatten(
const string_t& reference_string,
14454 const BasicJsonType& value,
14455 BasicJsonType& result)
14457 switch (
value.type())
14461 if (
value.m_data.m_value.array->empty())
14464 result[reference_string] =
nullptr;
14469 for (std::size_t i = 0; i <
value.m_data.m_value.array->size(); ++i)
14471 flatten(
detail::concat(reference_string,
'/', std::to_string(i)),
14472 value.m_data.m_value.array->operator[](i), result);
14480 if (
value.m_data.m_value.object->empty())
14483 result[reference_string] =
nullptr;
14488 for (
const auto& element : *
value.m_data.m_value.object)
14507 result[reference_string] =
value;
14523 template<
typename BasicJsonType>
14524 static BasicJsonType
14525 unflatten(
const BasicJsonType& value)
14532 BasicJsonType result;
14535 for (
const auto& element : *
value.m_data.m_value.object)
14546 json_pointer(element.first).get_and_create(result) = element.second;
14556 result.reference_tokens = reference_tokens;
14563 result.reference_tokens = std::move(reference_tokens);
14568#if JSON_HAS_THREE_WAY_COMPARISON
14571 template<
typename RefStringTypeRhs>
14574 return reference_tokens == rhs.reference_tokens;
14586 template<
typename RefStringTypeRhs>
14589 return reference_tokens <=> rhs.reference_tokens;
14594 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14601 template<
typename RefStringTypeLhs,
typename StringType>
14604 const StringType& rhs);
14608 template<
typename RefStringTypeRhs,
typename StringType>
14610 friend bool operator==(
const StringType& lhs,
14615 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14622 template<
typename RefStringTypeLhs,
typename StringType>
14625 const StringType& rhs);
14629 template<
typename RefStringTypeRhs,
typename StringType>
14631 friend bool operator!=(
const StringType& lhs,
14635 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14643 std::vector<string_t> reference_tokens;
14646#if !JSON_HAS_THREE_WAY_COMPARISON
14648template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14652 return lhs.reference_tokens == rhs.reference_tokens;
14655template<
typename RefStringTypeLhs,
14659 const StringType& rhs)
14664template<
typename RefStringTypeRhs,
14667inline
bool operator==(const StringType& lhs,
14673template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14677 return !(lhs == rhs);
14680template<
typename RefStringTypeLhs,
14684 const StringType& rhs)
14686 return !(lhs == rhs);
14689template<
typename RefStringTypeRhs,
14692inline
bool operator!=(const StringType& lhs,
14695 return !(lhs == rhs);
14698template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14702 return lhs.reference_tokens < rhs.reference_tokens;
14719#include <initializer_list>
14731 template<
typename BasicJsonType>
14742 : value_ref(&
value)
14746 : owned_value(init)
14753 : owned_value(
std::forward<Args>(args)...)
14765 if (value_ref ==
nullptr)
14767 return std::move(owned_value);
14774 return value_ref ? *value_ref : owned_value;
14811#include <algorithm>
14837#include <algorithm>
14871 template<typename CharType>
14875 template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
14889 void write_characters(const CharType* s,
std::
size_t length)
override
14891 v.insert(v.end(), s, s + length);
14895 std::vector<CharType, AllocatorType>& v;
14900 template<
typename CharType>
14914 void write_characters(const CharType* s,
std::
size_t length)
override
14916 stream.write(s,
static_cast<std::streamsize
>(length));
14920 std::basic_ostream<CharType>& stream;
14925 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14939 void write_characters(const CharType* s,
std::
size_t length)
override
14941 str.append(s, length);
14948 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14952 template<
typename AllocatorType = std::allocator<CharType>>
14990 template<
typename BasicJsonType,
typename CharType>
14993 using string_t =
typename BasicJsonType::string_t;
14994 using binary_t =
typename BasicJsonType::binary_t;
14995 using number_float_t =
typename BasicJsonType::number_float_t;
15016 case value_t::object:
15018 write_bson_object(*j.m_data.m_value.object);
15022 case value_t::null:
15023 case value_t::array:
15024 case value_t::string:
15025 case value_t::boolean:
15026 case value_t::number_integer:
15027 case value_t::number_unsigned:
15028 case value_t::number_float:
15029 case value_t::binary:
15030 case value_t::discarded:
15033 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
15045 case value_t::null:
15047 oa->write_character(to_char_type(0xF6));
15051 case value_t::boolean:
15053 oa->write_character(j.m_data.m_value.boolean
15054 ? to_char_type(0xF5)
15055 : to_char_type(0xF4));
15059 case value_t::number_integer:
15061 if (j.m_data.m_value.number_integer >= 0)
15066 if (j.m_data.m_value.number_integer <= 0x17)
15068 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15070 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15072 oa->write_character(to_char_type(0x18));
15073 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15075 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15077 oa->write_character(to_char_type(0x19));
15078 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15080 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15082 oa->write_character(to_char_type(0x1A));
15083 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15087 oa->write_character(to_char_type(0x1B));
15088 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15095 const auto positive_number = -1 - j.m_data.m_value.number_integer;
15096 if (j.m_data.m_value.number_integer >= -24)
15098 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
15100 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15102 oa->write_character(to_char_type(0x38));
15103 write_number(
static_cast<std::uint8_t
>(positive_number));
15105 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15107 oa->write_character(to_char_type(0x39));
15108 write_number(
static_cast<std::uint16_t
>(positive_number));
15110 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15112 oa->write_character(to_char_type(0x3A));
15113 write_number(
static_cast<std::uint32_t
>(positive_number));
15117 oa->write_character(to_char_type(0x3B));
15118 write_number(
static_cast<std::uint64_t
>(positive_number));
15124 case value_t::number_unsigned:
15126 if (j.m_data.m_value.number_unsigned <= 0x17)
15128 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15130 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15132 oa->write_character(to_char_type(0x18));
15133 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15135 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15137 oa->write_character(to_char_type(0x19));
15138 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_unsigned));
15140 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15142 oa->write_character(to_char_type(0x1A));
15143 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_unsigned));
15147 oa->write_character(to_char_type(0x1B));
15148 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned));
15153 case value_t::number_float:
15155 if (std::isnan(j.m_data.m_value.number_float))
15158 oa->write_character(to_char_type(0xF9));
15159 oa->write_character(to_char_type(0x7E));
15160 oa->write_character(to_char_type(0x00));
15162 else if (std::isinf(j.m_data.m_value.number_float))
15165 oa->write_character(to_char_type(0xf9));
15166 oa->write_character(j.m_data.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
15167 oa->write_character(to_char_type(0x00));
15176 case value_t::string:
15179 const auto N = j.m_data.m_value.string->size();
15182 write_number(
static_cast<std::uint8_t
>(0x60 + N));
15184 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15186 oa->write_character(to_char_type(0x78));
15187 write_number(
static_cast<std::uint8_t
>(N));
15189 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15191 oa->write_character(to_char_type(0x79));
15192 write_number(
static_cast<std::uint16_t
>(N));
15194 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15196 oa->write_character(to_char_type(0x7A));
15197 write_number(
static_cast<std::uint32_t
>(N));
15200 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15202 oa->write_character(to_char_type(0x7B));
15203 write_number(
static_cast<std::uint64_t
>(N));
15208 oa->write_characters(
15209 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15210 j.m_data.m_value.string->size());
15214 case value_t::array:
15217 const auto N = j.m_data.m_value.array->size();
15220 write_number(
static_cast<std::uint8_t
>(0x80 + N));
15222 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15224 oa->write_character(to_char_type(0x98));
15225 write_number(
static_cast<std::uint8_t
>(N));
15227 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15229 oa->write_character(to_char_type(0x99));
15230 write_number(
static_cast<std::uint16_t
>(N));
15232 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15234 oa->write_character(to_char_type(0x9A));
15235 write_number(
static_cast<std::uint32_t
>(N));
15238 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15240 oa->write_character(to_char_type(0x9B));
15241 write_number(
static_cast<std::uint64_t
>(N));
15246 for (
const auto& el : *j.m_data.m_value.array)
15253 case value_t::binary:
15255 if (j.m_data.m_value.binary->has_subtype())
15257 if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
15259 write_number(
static_cast<std::uint8_t
>(0xd8));
15260 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.binary->subtype()));
15262 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
15264 write_number(
static_cast<std::uint8_t
>(0xd9));
15265 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.binary->subtype()));
15267 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
15269 write_number(
static_cast<std::uint8_t
>(0xda));
15270 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.binary->subtype()));
15272 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
15274 write_number(
static_cast<std::uint8_t
>(0xdb));
15275 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.binary->subtype()));
15280 const auto N = j.m_data.m_value.binary->size();
15283 write_number(
static_cast<std::uint8_t
>(0x40 + N));
15285 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15287 oa->write_character(to_char_type(0x58));
15288 write_number(
static_cast<std::uint8_t
>(N));
15290 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15292 oa->write_character(to_char_type(0x59));
15293 write_number(
static_cast<std::uint16_t
>(N));
15295 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15297 oa->write_character(to_char_type(0x5A));
15298 write_number(
static_cast<std::uint32_t
>(N));
15301 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15303 oa->write_character(to_char_type(0x5B));
15304 write_number(
static_cast<std::uint64_t
>(N));
15309 oa->write_characters(
15310 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
15316 case value_t::object:
15319 const auto N = j.m_data.m_value.object->size();
15322 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
15324 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15326 oa->write_character(to_char_type(0xB8));
15327 write_number(
static_cast<std::uint8_t
>(N));
15329 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15331 oa->write_character(to_char_type(0xB9));
15332 write_number(
static_cast<std::uint16_t
>(N));
15334 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15336 oa->write_character(to_char_type(0xBA));
15337 write_number(
static_cast<std::uint32_t
>(N));
15340 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15342 oa->write_character(to_char_type(0xBB));
15343 write_number(
static_cast<std::uint64_t
>(N));
15348 for (
const auto& el : *j.m_data.m_value.object)
15350 write_cbor(el.first);
15351 write_cbor(el.second);
15356 case value_t::discarded:
15369 case value_t::null:
15371 oa->write_character(to_char_type(0xC0));
15375 case value_t::boolean:
15377 oa->write_character(j.m_data.m_value.boolean
15378 ? to_char_type(0xC3)
15379 : to_char_type(0xC2));
15383 case value_t::number_integer:
15385 if (j.m_data.m_value.number_integer >= 0)
15390 if (j.m_data.m_value.number_unsigned < 128)
15393 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15395 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15398 oa->write_character(to_char_type(0xCC));
15399 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15401 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15404 oa->write_character(to_char_type(0xCD));
15405 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15407 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15410 oa->write_character(to_char_type(0xCE));
15411 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15413 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15416 oa->write_character(to_char_type(0xCF));
15417 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15422 if (j.m_data.m_value.number_integer >= -32)
15425 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
15427 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
15428 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
15431 oa->write_character(to_char_type(0xD0));
15432 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
15434 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
15435 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15438 oa->write_character(to_char_type(0xD1));
15439 write_number(
static_cast<std::int16_t
>(j.m_data.m_value.number_integer));
15441 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
15442 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15445 oa->write_character(to_char_type(0xD2));
15446 write_number(
static_cast<std::int32_t
>(j.m_data.m_value.number_integer));
15448 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
15449 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15452 oa->write_character(to_char_type(0xD3));
15453 write_number(
static_cast<std::int64_t
>(j.m_data.m_value.number_integer));
15459 case value_t::number_unsigned:
15461 if (j.m_data.m_value.number_unsigned < 128)
15464 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15466 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15469 oa->write_character(to_char_type(0xCC));
15470 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15472 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15475 oa->write_character(to_char_type(0xCD));
15476 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15478 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15481 oa->write_character(to_char_type(0xCE));
15482 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15484 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15487 oa->write_character(to_char_type(0xCF));
15488 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15493 case value_t::number_float:
15499 case value_t::string:
15502 const auto N = j.m_data.m_value.string->size();
15506 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
15508 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15511 oa->write_character(to_char_type(0xD9));
15512 write_number(
static_cast<std::uint8_t
>(N));
15514 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15517 oa->write_character(to_char_type(0xDA));
15518 write_number(
static_cast<std::uint16_t
>(N));
15520 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15523 oa->write_character(to_char_type(0xDB));
15524 write_number(
static_cast<std::uint32_t
>(N));
15528 oa->write_characters(
15529 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15530 j.m_data.m_value.string->size());
15534 case value_t::array:
15537 const auto N = j.m_data.m_value.array->size();
15541 write_number(
static_cast<std::uint8_t
>(0x90 | N));
15543 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15546 oa->write_character(to_char_type(0xDC));
15547 write_number(
static_cast<std::uint16_t
>(N));
15549 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15552 oa->write_character(to_char_type(0xDD));
15553 write_number(
static_cast<std::uint32_t
>(N));
15557 for (
const auto& el : *j.m_data.m_value.array)
15564 case value_t::binary:
15568 const bool use_ext = j.m_data.m_value.binary->has_subtype();
15571 const auto N = j.m_data.m_value.binary->size();
15572 if (N <= (std::numeric_limits<std::uint8_t>::max)())
15574 std::uint8_t output_type{};
15581 output_type = 0xD4;
15584 output_type = 0xD5;
15587 output_type = 0xD6;
15590 output_type = 0xD7;
15593 output_type = 0xD8;
15596 output_type = 0xC7;
15604 output_type = 0xC4;
15608 oa->write_character(to_char_type(output_type));
15611 write_number(
static_cast<std::uint8_t
>(N));
15614 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15616 const std::uint8_t output_type = use_ext
15620 oa->write_character(to_char_type(output_type));
15621 write_number(
static_cast<std::uint16_t
>(N));
15623 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15625 const std::uint8_t output_type = use_ext
15629 oa->write_character(to_char_type(output_type));
15630 write_number(
static_cast<std::uint32_t
>(N));
15636 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.binary->subtype()));
15640 oa->write_characters(
15641 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
15647 case value_t::object:
15650 const auto N = j.m_data.m_value.object->size();
15654 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
15656 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15659 oa->write_character(to_char_type(0xDE));
15660 write_number(
static_cast<std::uint16_t
>(N));
15662 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15665 oa->write_character(to_char_type(0xDF));
15666 write_number(
static_cast<std::uint32_t
>(N));
15670 for (
const auto& el : *j.m_data.m_value.object)
15672 write_msgpack(el.first);
15673 write_msgpack(el.second);
15678 case value_t::discarded:
15692 const bool use_type,
const bool add_prefix =
true,
15693 const bool use_bjdata =
false)
15697 case value_t::null:
15701 oa->write_character(to_char_type(
'Z'));
15706 case value_t::boolean:
15710 oa->write_character(j.m_data.m_value.boolean
15711 ? to_char_type(
'T')
15712 : to_char_type(
'F'));
15717 case value_t::number_integer:
15719 write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata);
15723 case value_t::number_unsigned:
15725 write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
15729 case value_t::number_float:
15731 write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata);
15735 case value_t::string:
15739 oa->write_character(to_char_type(
'S'));
15741 write_number_with_ubjson_prefix(j.m_data.m_value.string->size(),
true, use_bjdata);
15742 oa->write_characters(
15743 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15744 j.m_data.m_value.string->size());
15748 case value_t::array:
15752 oa->write_character(to_char_type(
'['));
15755 bool prefix_required =
true;
15756 if (use_type && !j.m_data.m_value.array->empty())
15759 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15760 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
15761 [
this, first_prefix, use_bjdata](
const BasicJsonType& v)
15763 return ubjson_prefix(v, use_bjdata) == first_prefix;
15766 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z' };
15768 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15770 prefix_required =
false;
15771 oa->write_character(to_char_type(
'$'));
15772 oa->write_character(first_prefix);
15778 oa->write_character(to_char_type(
'#'));
15779 write_number_with_ubjson_prefix(j.m_data.m_value.array->size(),
true, use_bjdata);
15782 for (
const auto& el : *j.m_data.m_value.array)
15784 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
15789 oa->write_character(to_char_type(
']'));
15795 case value_t::binary:
15799 oa->write_character(to_char_type(
'['));
15802 if (use_type && !j.m_data.m_value.binary->empty())
15805 oa->write_character(to_char_type(
'$'));
15806 oa->write_character(
'U');
15811 oa->write_character(to_char_type(
'#'));
15812 write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(),
true, use_bjdata);
15817 oa->write_characters(
15818 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
15819 j.m_data.m_value.binary->size());
15823 for (
size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
15825 oa->write_character(to_char_type(
'U'));
15826 oa->write_character(j.m_data.m_value.binary->data()[i]);
15832 oa->write_character(to_char_type(
']'));
15838 case value_t::object:
15840 if (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find(
"_ArrayType_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArraySize_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArrayData_") != j.m_data.m_value.object->end())
15842 if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type))
15850 oa->write_character(to_char_type(
'{'));
15853 bool prefix_required =
true;
15854 if (use_type && !j.m_data.m_value.object->empty())
15857 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15858 const bool same_prefix = std::all_of(j.begin(), j.end(),
15859 [
this, first_prefix, use_bjdata](
const BasicJsonType& v)
15861 return ubjson_prefix(v, use_bjdata) == first_prefix;
15864 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z' };
15866 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15868 prefix_required =
false;
15869 oa->write_character(to_char_type(
'$'));
15870 oa->write_character(first_prefix);
15876 oa->write_character(to_char_type(
'#'));
15877 write_number_with_ubjson_prefix(j.m_data.m_value.object->size(),
true, use_bjdata);
15880 for (
const auto& el : *j.m_data.m_value.object)
15882 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
15883 oa->write_characters(
15884 reinterpret_cast<const CharType*
>(el.first.c_str()),
15886 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
15891 oa->write_character(to_char_type(
'}'));
15897 case value_t::discarded:
15912 static std::size_t calc_bson_entry_header_size(
const string_t& name,
const BasicJsonType& j)
15914 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
15917 JSON_THROW(out_of_range::create(409,
concat(
"BSON key cannot contain code point U+0000 (at byte ", std::to_string(it),
")"), &j));
15918 static_cast<void>(j);
15921 return 1ul + name.size() + 1u;
15927 void write_bson_entry_header(
const string_t& name,
15928 const std::uint8_t element_type)
15930 oa->write_character(to_char_type(element_type));
15931 oa->write_characters(
15932 reinterpret_cast<const CharType*
>(name.c_str()),
15939 void write_bson_boolean(
const string_t& name,
15942 write_bson_entry_header(name, 0x08);
15943 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
15949 void write_bson_double(
const string_t& name,
15950 const double value)
15952 write_bson_entry_header(name, 0x01);
15953 write_number<double>(value,
true);
15959 static std::size_t calc_bson_string_size(
const string_t& value)
15961 return sizeof(std::int32_t) +
value.size() + 1ul;
15967 void write_bson_string(
const string_t& name,
15968 const string_t& value)
15970 write_bson_entry_header(name, 0x02);
15972 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
15973 oa->write_characters(
15974 reinterpret_cast<const CharType*
>(
value.c_str()),
15981 void write_bson_null(
const string_t& name)
15983 write_bson_entry_header(name, 0x0A);
15989 static std::size_t calc_bson_integer_size(
const std::int64_t value)
15991 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
15992 ?
sizeof(std::int32_t)
15993 :
sizeof(std::int64_t);
15999 void write_bson_integer(
const string_t& name,
16000 const std::int64_t value)
16002 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
16004 write_bson_entry_header(name, 0x10);
16005 write_number<std::int32_t>(
static_cast<std::int32_t
>(value),
true);
16009 write_bson_entry_header(name, 0x12);
16010 write_number<std::int64_t>(
static_cast<std::int64_t
>(value),
true);
16017 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t value)
noexcept
16019 return (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16020 ?
sizeof(std::int32_t)
16021 :
sizeof(std::int64_t);
16027 void write_bson_unsigned(
const string_t& name,
16028 const BasicJsonType& j)
16030 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16032 write_bson_entry_header(name, 0x10 );
16033 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_data.m_value.number_unsigned),
true);
16035 else if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16037 write_bson_entry_header(name, 0x12 );
16038 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_data.m_value.number_unsigned),
true);
16042 JSON_THROW(out_of_range::create(407,
concat(
"integer number ", std::to_string(j.m_data.m_value.number_unsigned),
" cannot be represented by BSON as it does not fit int64"), &j));
16049 void write_bson_object_entry(
const string_t& name,
16050 const typename BasicJsonType::object_t& value)
16052 write_bson_entry_header(name, 0x03);
16053 write_bson_object(value);
16059 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t& value)
16061 std::size_t array_index = 0ul;
16063 const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value),
static_cast<std::size_t
>(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type& el)
16065 return result + calc_bson_element_size(std::to_string(array_index++), el);
16068 return sizeof(std::int32_t) + embedded_document_size + 1ul;
16074 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t& value)
16076 return sizeof(std::int32_t) +
value.size() + 1ul;
16082 void write_bson_array(
const string_t& name,
16083 const typename BasicJsonType::array_t& value)
16085 write_bson_entry_header(name, 0x04);
16086 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(value)),
true);
16088 std::size_t array_index = 0ul;
16090 for (
const auto& el : value)
16092 write_bson_element(std::to_string(array_index++), el);
16095 oa->write_character(to_char_type(0x00));
16101 void write_bson_binary(
const string_t& name,
16102 const binary_t& value)
16104 write_bson_entry_header(name, 0x05);
16106 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
16107 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
16109 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
16116 static std::size_t calc_bson_element_size(
const string_t& name,
16117 const BasicJsonType& j)
16119 const auto header_size = calc_bson_entry_header_size(name, j);
16122 case value_t::object:
16123 return header_size + calc_bson_object_size(*j.m_data.m_value.object);
16125 case value_t::array:
16126 return header_size + calc_bson_array_size(*j.m_data.m_value.array);
16128 case value_t::binary:
16129 return header_size + calc_bson_binary_size(*j.m_data.m_value.binary);
16131 case value_t::boolean:
16132 return header_size + 1ul;
16134 case value_t::number_float:
16135 return header_size + 8ul;
16137 case value_t::number_integer:
16138 return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer);
16140 case value_t::number_unsigned:
16141 return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned);
16143 case value_t::string:
16144 return header_size + calc_bson_string_size(*j.m_data.m_value.string);
16146 case value_t::null:
16147 return header_size + 0ul;
16150 case value_t::discarded:
16164 void write_bson_element(
const string_t& name,
16165 const BasicJsonType& j)
16169 case value_t::object:
16170 return write_bson_object_entry(name, *j.m_data.m_value.object);
16172 case value_t::array:
16173 return write_bson_array(name, *j.m_data.m_value.array);
16175 case value_t::binary:
16176 return write_bson_binary(name, *j.m_data.m_value.binary);
16178 case value_t::boolean:
16179 return write_bson_boolean(name, j.m_data.m_value.boolean);
16181 case value_t::number_float:
16182 return write_bson_double(name, j.m_data.m_value.number_float);
16184 case value_t::number_integer:
16185 return write_bson_integer(name, j.m_data.m_value.number_integer);
16187 case value_t::number_unsigned:
16188 return write_bson_unsigned(name, j);
16190 case value_t::string:
16191 return write_bson_string(name, *j.m_data.m_value.string);
16193 case value_t::null:
16194 return write_bson_null(name);
16197 case value_t::discarded:
16211 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t& value)
16213 const std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
16214 [](
size_t result,
const typename BasicJsonType::object_t::value_type& el)
16216 return result += calc_bson_element_size(el.first, el.second);
16219 return sizeof(std::int32_t) + document_size + 1ul;
16226 void write_bson_object(
const typename BasicJsonType::object_t& value)
16228 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(value)),
true);
16230 for (
const auto& el : value)
16232 write_bson_element(el.first, el.second);
16235 oa->write_character(to_char_type(0x00));
16242 static constexpr CharType get_cbor_float_prefix(
float )
16244 return to_char_type(0xFA);
16247 static constexpr CharType get_cbor_float_prefix(
double )
16249 return to_char_type(0xFB);
16256 static constexpr CharType get_msgpack_float_prefix(
float )
16258 return to_char_type(0xCA);
16261 static constexpr CharType get_msgpack_float_prefix(
double )
16263 return to_char_type(0xCB);
16271 template<
typename NumberType,
typename std::enable_if<
16272 std::is_floating_point<NumberType>::value,
int>::type = 0>
16273 void write_number_with_ubjson_prefix(
const NumberType n,
16274 const bool add_prefix,
16275 const bool use_bjdata)
16279 oa->write_character(get_ubjson_float_prefix(n));
16281 write_number(n, use_bjdata);
16285 template<
typename NumberType,
typename std::enable_if<
16286 std::is_unsigned<NumberType>::value,
int>::type = 0>
16287 void write_number_with_ubjson_prefix(
const NumberType n,
16288 const bool add_prefix,
16289 const bool use_bjdata)
16291 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16295 oa->write_character(to_char_type(
'i'));
16297 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16299 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
16303 oa->write_character(to_char_type(
'U'));
16305 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16307 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16311 oa->write_character(to_char_type(
'I'));
16313 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16315 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
16319 oa->write_character(to_char_type(
'u'));
16321 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
16323 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16327 oa->write_character(to_char_type(
'l'));
16329 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16331 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
16335 oa->write_character(to_char_type(
'm'));
16337 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
16339 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16343 oa->write_character(to_char_type(
'L'));
16345 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16347 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
16351 oa->write_character(to_char_type(
'M'));
16353 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
16359 oa->write_character(to_char_type(
'H'));
16362 const auto number = BasicJsonType(n).dump();
16363 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16364 for (std::size_t i = 0; i < number.size(); ++i)
16366 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16372 template <
typename NumberType,
typename std::enable_if <
16373 std::is_signed<NumberType>::value &&
16374 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
16375 void write_number_with_ubjson_prefix(
const NumberType n,
16376 const bool add_prefix,
16377 const bool use_bjdata)
16379 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
16383 oa->write_character(to_char_type(
'i'));
16385 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
16387 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
16391 oa->write_character(to_char_type(
'U'));
16393 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16395 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
16399 oa->write_character(to_char_type(
'I'));
16401 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16403 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::max)())))
16407 oa->write_character(to_char_type(
'u'));
16409 write_number(
static_cast<uint16_t
>(n), use_bjdata);
16411 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
16415 oa->write_character(to_char_type(
'l'));
16417 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16419 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::max)())))
16423 oa->write_character(to_char_type(
'm'));
16425 write_number(
static_cast<uint32_t
>(n), use_bjdata);
16427 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
16431 oa->write_character(to_char_type(
'L'));
16433 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16440 oa->write_character(to_char_type(
'H'));
16443 const auto number = BasicJsonType(n).dump();
16444 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16445 for (std::size_t i = 0; i < number.size(); ++i)
16447 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16456 CharType ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
16460 case value_t::null:
16463 case value_t::boolean:
16464 return j.m_data.m_value.boolean ?
'T' :
'F';
16466 case value_t::number_integer:
16468 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16472 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
16476 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16480 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
16484 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16488 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
16492 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16500 case value_t::number_unsigned:
16502 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16506 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
16510 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16514 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
16518 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16522 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
16526 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16530 if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16538 case value_t::number_float:
16539 return get_ubjson_float_prefix(j.m_data.m_value.number_float);
16541 case value_t::string:
16544 case value_t::array:
16545 case value_t::binary:
16548 case value_t::object:
16551 case value_t::discarded:
16557 static constexpr CharType get_ubjson_float_prefix(
float )
16562 static constexpr CharType get_ubjson_float_prefix(
double )
16570 bool write_bjdata_ndarray(
const typename BasicJsonType::object_t& value,
const bool use_count,
const bool use_type)
16572 std::map<string_t, CharType> bjdtype = { {
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
16573 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
16576 string_t
key =
"_ArrayType_";
16577 auto it = bjdtype.find(
static_cast<string_t
>(
value.at(key)));
16578 if (it == bjdtype.end())
16582 CharType dtype = it->second;
16584 key =
"_ArraySize_";
16585 std::size_t len = (
value.at(key).empty() ? 0 : 1);
16586 for (
const auto& el :
value.at(key))
16588 len *=
static_cast<std::size_t
>(el.m_data.m_value.number_unsigned);
16591 key =
"_ArrayData_";
16592 if (
value.at(key).size() != len)
16597 oa->write_character(
'[');
16598 oa->write_character(
'$');
16599 oa->write_character(dtype);
16600 oa->write_character(
'#');
16602 key =
"_ArraySize_";
16603 write_ubjson(
value.at(key), use_count, use_type,
true,
true);
16605 key =
"_ArrayData_";
16606 if (dtype ==
'U' || dtype ==
'C')
16608 for (
const auto& el :
value.at(key))
16610 write_number(
static_cast<std::uint8_t
>(el.m_data.m_value.number_unsigned),
true);
16613 else if (dtype ==
'i')
16615 for (
const auto& el :
value.at(key))
16617 write_number(
static_cast<std::int8_t
>(el.m_data.m_value.number_integer),
true);
16620 else if (dtype ==
'u')
16622 for (
const auto& el :
value.at(key))
16624 write_number(
static_cast<std::uint16_t
>(el.m_data.m_value.number_unsigned),
true);
16627 else if (dtype ==
'I')
16629 for (
const auto& el :
value.at(key))
16631 write_number(
static_cast<std::int16_t
>(el.m_data.m_value.number_integer),
true);
16634 else if (dtype ==
'm')
16636 for (
const auto& el :
value.at(key))
16638 write_number(
static_cast<std::uint32_t
>(el.m_data.m_value.number_unsigned),
true);
16641 else if (dtype ==
'l')
16643 for (
const auto& el :
value.at(key))
16645 write_number(
static_cast<std::int32_t
>(el.m_data.m_value.number_integer),
true);
16648 else if (dtype ==
'M')
16650 for (
const auto& el :
value.at(key))
16652 write_number(
static_cast<std::uint64_t
>(el.m_data.m_value.number_unsigned),
true);
16655 else if (dtype ==
'L')
16657 for (
const auto& el :
value.at(key))
16659 write_number(
static_cast<std::int64_t
>(el.m_data.m_value.number_integer),
true);
16662 else if (dtype ==
'd')
16664 for (
const auto& el :
value.at(key))
16666 write_number(
static_cast<float>(el.m_data.m_value.number_float),
true);
16669 else if (dtype ==
'D')
16671 for (
const auto& el :
value.at(key))
16673 write_number(
static_cast<double>(el.m_data.m_value.number_float),
true);
16696 template<
typename NumberType>
16697 void write_number(
const NumberType n,
const bool OutputIsLittleEndian =
false)
16700 std::array<CharType,
sizeof(NumberType)> vec{};
16701 std::memcpy(vec.data(), &n,
sizeof(NumberType));
16704 if (is_little_endian != OutputIsLittleEndian)
16707 std::reverse(vec.begin(), vec.end());
16710 oa->write_characters(vec.data(),
sizeof(NumberType));
16716#pragma GCC diagnostic push
16717#pragma GCC diagnostic ignored "-Wfloat-equal"
16719 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
16720 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
16721 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
16724 ? get_cbor_float_prefix(
static_cast<float>(n))
16725 : get_msgpack_float_prefix(
static_cast<float>(n)));
16726 write_number(
static_cast<float>(n));
16731 ? get_cbor_float_prefix(n)
16732 : get_msgpack_float_prefix(n));
16736#pragma GCC diagnostic pop
16745 template <
typename C = CharType,
16746 enable_if_t < std::is_signed<C>::value&& std::is_signed<char>::value >* =
nullptr >
16749 return *
reinterpret_cast<char*
>(&x);
16752 template <
typename C = CharType,
16753 enable_if_t < std::is_signed<C>::value&& std::is_unsigned<char>::value >* =
nullptr >
16756 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
16757 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
16759 std::memcpy(&result, &x,
sizeof(x));
16763 template<
typename C = CharType,
16770 template <
typename InputCharType,
typename C = CharType,
16772 std::is_signed<C>::value&&
16773 std::is_signed<char>::value&&
16774 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
16783 const bool is_little_endian = little_endianness();
16806#include <algorithm>
16816#include <type_traits>
16836#include <type_traits>
16864 namespace dtoa_impl
16867 template<
typename Target,
typename Source>
16870 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
16873 std::memcpy(&target, &source,
sizeof(Source));
16884 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_),
e(e_) {}
16895 return { x.f - y.f, x.e };
16904 static_assert(
kPrecision == 64,
"internal error");
16929 const std::uint64_t u_lo = x.
f & 0xFFFFFFFFu;
16930 const std::uint64_t u_hi = x.f >> 32u;
16931 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
16932 const std::uint64_t v_hi = y.f >> 32u;
16934 const std::uint64_t p0 = u_lo * v_lo;
16935 const std::uint64_t p1 = u_lo * v_hi;
16936 const std::uint64_t p2 = u_hi * v_lo;
16937 const std::uint64_t p3 = u_hi * v_hi;
16939 const std::uint64_t p0_hi = p0 >> 32u;
16940 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
16941 const std::uint64_t p1_hi = p1 >> 32u;
16942 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
16943 const std::uint64_t p2_hi = p2 >> 32u;
16945 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
16956 Q += std::uint64_t{ 1 } << (64u - 32u - 1u);
16958 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
16960 return { h, x.e + y.e + 64 };
16971 while ((x.f >> 63u) == 0)
16986 const int delta = x.
e - target_exponent;
16991 return { x.f << delta, target_exponent };
17008 template<
typename FloatType>
17021 static_assert(std::numeric_limits<FloatType>::is_iec559,
17022 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
17024 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
17025 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
17026 constexpr int kMinExp = 1 - kBias;
17027 constexpr std::uint64_t kHiddenBit = std::uint64_t{ 1 } << (kPrecision - 1);
17029 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
17031 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
17032 const std::uint64_t E = bits >> (kPrecision - 1);
17033 const std::uint64_t F = bits & (kHiddenBit - 1);
17035 const bool is_denormal = E == 0;
17036 const diyfp v = is_denormal
17037 ?
diyfp(F, kMinExp)
17038 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
17061 const bool lower_boundary_is_closer = F == 0 && E > 1;
17063 const diyfp m_minus = lower_boundary_is_closer
17064 ?
diyfp(4 * v.
f - 1, v.
e - 2)
17065 :
diyfp(2 * v.
f - 1, v.
e - 1);
17200 constexpr int kCachedPowersMinDecExp = -300;
17201 constexpr int kCachedPowersDecStep = 8;
17203 static constexpr std::array<cached_power, 79> kCachedPowers =
17206 { 0xAB70FE17C79AC6CA, -1060, -300 },
17207 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
17208 { 0xBE5691EF416BD60C, -1007, -284 },
17209 { 0x8DD01FAD907FFC3C, -980, -276 },
17210 { 0xD3515C2831559A83, -954, -268 },
17211 { 0x9D71AC8FADA6C9B5, -927, -260 },
17212 { 0xEA9C227723EE8BCB, -901, -252 },
17213 { 0xAECC49914078536D, -874, -244 },
17214 { 0x823C12795DB6CE57, -847, -236 },
17215 { 0xC21094364DFB5637, -821, -228 },
17216 { 0x9096EA6F3848984F, -794, -220 },
17217 { 0xD77485CB25823AC7, -768, -212 },
17218 { 0xA086CFCD97BF97F4, -741, -204 },
17219 { 0xEF340A98172AACE5, -715, -196 },
17220 { 0xB23867FB2A35B28E, -688, -188 },
17221 { 0x84C8D4DFD2C63F3B, -661, -180 },
17222 { 0xC5DD44271AD3CDBA, -635, -172 },
17223 { 0x936B9FCEBB25C996, -608, -164 },
17224 { 0xDBAC6C247D62A584, -582, -156 },
17225 { 0xA3AB66580D5FDAF6, -555, -148 },
17226 { 0xF3E2F893DEC3F126, -529, -140 },
17227 { 0xB5B5ADA8AAFF80B8, -502, -132 },
17228 { 0x87625F056C7C4A8B, -475, -124 },
17229 { 0xC9BCFF6034C13053, -449, -116 },
17230 { 0x964E858C91BA2655, -422, -108 },
17231 { 0xDFF9772470297EBD, -396, -100 },
17232 { 0xA6DFBD9FB8E5B88F, -369, -92 },
17233 { 0xF8A95FCF88747D94, -343, -84 },
17234 { 0xB94470938FA89BCF, -316, -76 },
17235 { 0x8A08F0F8BF0F156B, -289, -68 },
17236 { 0xCDB02555653131B6, -263, -60 },
17237 { 0x993FE2C6D07B7FAC, -236, -52 },
17238 { 0xE45C10C42A2B3B06, -210, -44 },
17239 { 0xAA242499697392D3, -183, -36 },
17240 { 0xFD87B5F28300CA0E, -157, -28 },
17241 { 0xBCE5086492111AEB, -130, -20 },
17242 { 0x8CBCCC096F5088CC, -103, -12 },
17243 { 0xD1B71758E219652C, -77, -4 },
17244 { 0x9C40000000000000, -50, 4 },
17245 { 0xE8D4A51000000000, -24, 12 },
17246 { 0xAD78EBC5AC620000, 3, 20 },
17247 { 0x813F3978F8940984, 30, 28 },
17248 { 0xC097CE7BC90715B3, 56, 36 },
17249 { 0x8F7E32CE7BEA5C70, 83, 44 },
17250 { 0xD5D238A4ABE98068, 109, 52 },
17251 { 0x9F4F2726179A2245, 136, 60 },
17252 { 0xED63A231D4C4FB27, 162, 68 },
17253 { 0xB0DE65388CC8ADA8, 189, 76 },
17254 { 0x83C7088E1AAB65DB, 216, 84 },
17255 { 0xC45D1DF942711D9A, 242, 92 },
17256 { 0x924D692CA61BE758, 269, 100 },
17257 { 0xDA01EE641A708DEA, 295, 108 },
17258 { 0xA26DA3999AEF774A, 322, 116 },
17259 { 0xF209787BB47D6B85, 348, 124 },
17260 { 0xB454E4A179DD1877, 375, 132 },
17261 { 0x865B86925B9BC5C2, 402, 140 },
17262 { 0xC83553C5C8965D3D, 428, 148 },
17263 { 0x952AB45CFA97A0B3, 455, 156 },
17264 { 0xDE469FBD99A05FE3, 481, 164 },
17265 { 0xA59BC234DB398C25, 508, 172 },
17266 { 0xF6C69A72A3989F5C, 534, 180 },
17267 { 0xB7DCBF5354E9BECE, 561, 188 },
17268 { 0x88FCF317F22241E2, 588, 196 },
17269 { 0xCC20CE9BD35C78A5, 614, 204 },
17270 { 0x98165AF37B2153DF, 641, 212 },
17271 { 0xE2A0B5DC971F303A, 667, 220 },
17272 { 0xA8D9D1535CE3B396, 694, 228 },
17273 { 0xFB9B7CD9A4A7443C, 720, 236 },
17274 { 0xBB764C4CA7A44410, 747, 244 },
17275 { 0x8BAB8EEFB6409C1A, 774, 252 },
17276 { 0xD01FEF10A657842C, 800, 260 },
17277 { 0x9B10A4E5E9913129, 827, 268 },
17278 { 0xE7109BFBA19C0C9D, 853, 276 },
17279 { 0xAC2820D9623BF429, 880, 284 },
17280 { 0x80444B5E7AA7CF85, 907, 292 },
17281 { 0xBF21E44003ACDD2D, 933, 300 },
17282 { 0x8E679C2F5E44FF8F, 960, 308 },
17283 { 0xD433179D9C8CB841, 986, 316 },
17284 { 0x9E19DB92B4E31BA9, 1013, 324 },
17294 const int f =
kAlpha - e - 1;
17295 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
17297 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
17299 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
17301 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
17315 if (n >= 1000000000)
17317 pow10 = 1000000000;
17321 if (n >= 100000000)
17366 inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
17367 std::uint64_t rest, std::uint64_t ten_k)
17394 && delta - rest >= ten_k
17395 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
17410 static_assert(
kAlpha >= -60,
"internal error");
17411 static_assert(
kGamma <= -32,
"internal error");
17428 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).
f;
17438 const diyfp one(std::uint64_t{ 1 } << -M_plus.
e, M_plus.
e);
17440 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
17441 std::uint64_t p2 = M_plus.
f & (one.f - 1);
17449 std::uint32_t pow10{};
17477 const std::uint32_t d = p1 / pow10;
17478 const std::uint32_t r = p1 % pow10;
17484 buffer[length++] =
static_cast<char>(
'0' + d);
17503 const std::uint64_t rest = (std::uint64_t{ p1 } << -one.e) + p2;
17508 decimal_exponent += n;
17519 const std::uint64_t ten_n = std::uint64_t{ pow10 } << -one.e;
17520 grisu2_round(buffer, length, dist, delta, rest, ten_n);
17581 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
17583 const std::uint64_t d = p2 >> -one.e;
17584 const std::uint64_t r = p2 & (one.f - 1);
17591 buffer[length++] =
static_cast<char>(
'0' + d);
17616 decimal_exponent -= m;
17624 const std::uint64_t ten_m = one.f;
17648 inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
17665 const diyfp c_minus_k(cached.
f, cached.
e);
17693 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
17694 const diyfp M_plus(w_plus.
f - 1, w_plus.
e);
17696 decimal_exponent = -cached.
k;
17706 template<
typename FloatType>
17711 "internal error: not enough precision");
17763 auto k =
static_cast<std::uint32_t
>(e);
17769 *buf++ =
static_cast<char>(
'0' + k);
17773 *buf++ =
static_cast<char>(
'0' + k / 10);
17775 *buf++ =
static_cast<char>(
'0' + k);
17779 *buf++ =
static_cast<char>(
'0' + k / 100);
17781 *buf++ =
static_cast<char>(
'0' + k / 10);
17783 *buf++ =
static_cast<char>(
'0' + k);
17801 int min_exp,
int max_exp)
17807 const int n = len + decimal_exponent;
17813 if (k <= n && n <= max_exp)
17818 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
17822 return buf + (
static_cast<size_t>(n) + 2);
17825 if (0 < n && n <= max_exp)
17832 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
17834 return buf + (
static_cast<size_t>(k) + 1U);
17837 if (min_exp < n && n <= 0)
17842 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
17845 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
17846 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
17861 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
17863 buf += 1 +
static_cast<size_t>(k);
17882 template<
typename FloatType>
17887 static_cast<void>(last);
17891 if (std::signbit(
value))
17898#pragma GCC diagnostic push
17899#pragma GCC diagnostic ignored "-Wfloat-equal"
17910#pragma GCC diagnostic pop
17913 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
17920 int decimal_exponent = 0;
17923 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
17926 constexpr int kMinExp = -4;
17928 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
17931 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
17932 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
17971 template<
typename BasicJsonType>
17974 using string_t =
typename BasicJsonType::string_t;
17975 using number_float_t =
typename BasicJsonType::number_float_t;
17976 using number_integer_t =
typename BasicJsonType::number_integer_t;
17977 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
17978 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
17979 static constexpr std::uint8_t UTF8_ACCEPT = 0;
17980 static constexpr std::uint8_t UTF8_REJECT = 1;
17991 ,
loc(
std::localeconv())
18029 const bool pretty_print,
18031 const unsigned int indent_step,
18032 const unsigned int current_indent = 0)
18034 switch (val.m_data.m_type)
18038 if (val.m_data.m_value.object->empty())
18040 o->write_characters(
"{}", 2);
18046 o->write_characters(
"{\n", 2);
18049 const auto new_indent = current_indent + indent_step;
18056 auto i = val.m_data.m_value.object->cbegin();
18057 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18060 o->write_character(
'\"');
18062 o->write_characters(
"\": ", 3);
18064 o->write_characters(
",\n", 2);
18068 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18069 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18071 o->write_character(
'\"');
18073 o->write_characters(
"\": ", 3);
18076 o->write_character(
'\n');
18077 o->write_characters(
indent_string.c_str(), current_indent);
18078 o->write_character(
'}');
18082 o->write_character(
'{');
18085 auto i = val.m_data.m_value.object->cbegin();
18086 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18088 o->write_character(
'\"');
18090 o->write_characters(
"\":", 2);
18092 o->write_character(
',');
18096 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18097 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18098 o->write_character(
'\"');
18100 o->write_characters(
"\":", 2);
18103 o->write_character(
'}');
18111 if (val.m_data.m_value.array->empty())
18113 o->write_characters(
"[]", 2);
18119 o->write_characters(
"[\n", 2);
18122 const auto new_indent = current_indent + indent_step;
18129 for (
auto i = val.m_data.m_value.array->cbegin();
18130 i != val.m_data.m_value.array->cend() - 1; ++i)
18134 o->write_characters(
",\n", 2);
18140 dump(val.m_data.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
18142 o->write_character(
'\n');
18143 o->write_characters(
indent_string.c_str(), current_indent);
18144 o->write_character(
']');
18148 o->write_character(
'[');
18151 for (
auto i = val.m_data.m_value.array->cbegin();
18152 i != val.m_data.m_value.array->cend() - 1; ++i)
18155 o->write_character(
',');
18160 dump(val.m_data.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
18162 o->write_character(
']');
18170 o->write_character(
'\"');
18171 dump_escaped(*val.m_data.m_value.string,
ensure_ascii);
18172 o->write_character(
'\"');
18180 o->write_characters(
"{\n", 2);
18183 const auto new_indent = current_indent + indent_step;
18191 o->write_characters(
"\"bytes\": [", 10);
18193 if (!val.m_data.m_value.binary->empty())
18195 for (
auto i = val.m_data.m_value.binary->cbegin();
18196 i != val.m_data.m_value.binary->cend() - 1; ++i)
18199 o->write_characters(
", ", 2);
18201 dump_integer(val.m_data.m_value.binary->back());
18204 o->write_characters(
"],\n", 3);
18207 o->write_characters(
"\"subtype\": ", 11);
18208 if (val.m_data.m_value.binary->has_subtype())
18210 dump_integer(val.m_data.m_value.binary->subtype());
18214 o->write_characters(
"null", 4);
18216 o->write_character(
'\n');
18217 o->write_characters(
indent_string.c_str(), current_indent);
18218 o->write_character(
'}');
18222 o->write_characters(
"{\"bytes\":[", 10);
18224 if (!val.m_data.m_value.binary->empty())
18226 for (
auto i = val.m_data.m_value.binary->cbegin();
18227 i != val.m_data.m_value.binary->cend() - 1; ++i)
18230 o->write_character(
',');
18232 dump_integer(val.m_data.m_value.binary->back());
18235 o->write_characters(
"],\"subtype\":", 12);
18236 if (val.m_data.m_value.binary->has_subtype())
18238 dump_integer(val.m_data.m_value.binary->subtype());
18239 o->write_character(
'}');
18243 o->write_characters(
"null}", 5);
18251 if (val.m_data.m_value.boolean)
18253 o->write_characters(
"true", 4);
18257 o->write_characters(
"false", 5);
18264 dump_integer(val.m_data.m_value.number_integer);
18270 dump_integer(val.m_data.m_value.number_unsigned);
18276 dump_float(val.m_data.m_value.number_float);
18282 o->write_characters(
"<discarded>", 11);
18288 o->write_characters(
"null", 4);
18314 std::uint32_t codepoint{};
18322 for (std::size_t i = 0; i < s.size(); ++i)
18324 const auto byte =
static_cast<std::uint8_t
>(s[i]);
18326 switch (decode(
state, codepoint,
byte))
18385 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
18387 if (codepoint <= 0xFFFF)
18391 static_cast<std::uint16_t
>(codepoint)));
18397 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
18398 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
18399 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
18487 state = UTF8_ACCEPT;
18543 o->write_characters(
"\\ufffd", 6);
18547 o->write_characters(
"\xEF\xBF\xBD", 3);
18567 inline unsigned int count_digits(number_unsigned_t x)
noexcept
18569 unsigned int n_digits = 1;
18578 return n_digits + 1;
18582 return n_digits + 2;
18586 return n_digits + 3;
18598 static std::string hex_bytes(std::uint8_t
byte)
18600 std::string result =
"FF";
18601 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
18602 result[0] = nibble_to_hex[
byte / 16];
18603 result[1] = nibble_to_hex[
byte % 16];
18608 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
18609 bool is_negative_number(NumberType x)
18614 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
18615 bool is_negative_number(NumberType )
18630 std::is_integral<NumberType>::value ||
18631 std::is_same<NumberType, number_unsigned_t>::value ||
18632 std::is_same<NumberType, number_integer_t>::value ||
18633 std::is_same<NumberType, binary_char_t>::value,
18635 void dump_integer(NumberType x)
18637 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
18640 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
18641 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
18642 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
18643 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
18644 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
18645 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
18646 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
18647 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
18648 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
18649 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
18656 o->write_character(
'0');
18663 number_unsigned_t abs_value;
18665 unsigned int n_chars{};
18667 if (is_negative_number(x))
18670 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
18673 n_chars = 1 + count_digits(abs_value);
18677 abs_value =
static_cast<number_unsigned_t
>(x);
18678 n_chars = count_digits(abs_value);
18686 buffer_ptr += n_chars;
18690 while (abs_value >= 100)
18692 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
18694 *(--buffer_ptr) = digits_to_99[digits_index][1];
18695 *(--buffer_ptr) = digits_to_99[digits_index][0];
18698 if (abs_value >= 10)
18700 const auto digits_index =
static_cast<unsigned>(abs_value);
18701 *(--buffer_ptr) = digits_to_99[digits_index][1];
18702 *(--buffer_ptr) = digits_to_99[digits_index][0];
18706 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
18720 void dump_float(number_float_t x)
18723 if (!std::isfinite(x))
18725 o->write_characters(
"null", 4);
18734 static constexpr bool is_ieee_single_or_double
18735 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
18736 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
18738 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
18741 void dump_float(number_float_t x, std::true_type )
18744 auto* end = ::nlohmann::detail::to_chars(begin, begin +
number_buffer.size(), x);
18746 o->write_characters(begin,
static_cast<size_t>(end - begin));
18749 void dump_float(number_float_t x, std::false_type )
18752 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
18784 o->write_characters(
number_buffer.data(),
static_cast<std::size_t
>(len));
18787 const bool value_is_int_like =
18791 return c ==
'.' || c ==
'e';
18794 if (value_is_int_like)
18796 o->write_characters(
".0", 2);
18821 static std::uint8_t decode(std::uint8_t&
state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
18823 static const std::array<std::uint8_t, 400> utf8d =
18826 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18827 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18828 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18829 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18830 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
18831 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
18832 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
18833 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
18834 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
18835 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
18836 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
18837 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
18838 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
18839 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
18844 const std::uint8_t type = utf8d[byte];
18846 codep = (
state != UTF8_ACCEPT)
18847 ? (
byte & 0x3fu) | (codep << 6u)
18848 : (0xFFu >> type) & (byte);
18850 const std::size_t index = 256u +
static_cast<size_t>(
state) * 16u +
static_cast<size_t>(type);
18852 state = utf8d[index];
18861 number_unsigned_t remove_sign(number_unsigned_t x)
18876 inline number_unsigned_t remove_sign(number_integer_t x)
noexcept
18878 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
18879 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
18884 output_adapter_t<char> o =
nullptr;
18926#include <functional>
18927#include <initializer_list>
18930#include <stdexcept>
18931#include <type_traits>
18944template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
18945 class Allocator = std::allocator<std::pair<const Key, T>>>
18950 using Container = std::vector<std::pair<const Key, T>, Allocator>;
18955#ifdef JSON_HAS_CPP_14
18965 template <
class It>
18968 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator())
18973 for (
auto it = this->begin(); it != this->end(); ++it)
18975 if (m_compare(it->first, key))
18977 return { it,
false };
18980 Container::emplace_back(key, std::forward<T>(t));
18981 return { std::prev(this->end()),
true };
18986 std::pair<iterator, bool>
emplace(KeyType&& key, T&& t)
18988 for (
auto it = this->begin(); it != this->end(); ++it)
18990 if (m_compare(it->first, key))
18992 return { it,
false };
18995 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
18996 return { std::prev(this->end()),
true };
19001 return emplace(key, T{}).first->second;
19008 return emplace(std::forward<KeyType>(key), T{}).first->second;
19020 return at(std::forward<KeyType>(key));
19025 for (
auto it = this->begin(); it != this->end(); ++it)
19027 if (m_compare(it->first, key))
19033 JSON_THROW(std::out_of_range(
"key not found"));
19040 for (
auto it = this->begin(); it != this->end(); ++it)
19042 if (m_compare(it->first, key))
19048 JSON_THROW(std::out_of_range(
"key not found"));
19053 for (
auto it = this->begin(); it != this->end(); ++it)
19055 if (m_compare(it->first, key))
19061 JSON_THROW(std::out_of_range(
"key not found"));
19066 const T&
at(KeyType&& key)
const
19068 for (
auto it = this->begin(); it != this->end(); ++it)
19070 if (m_compare(it->first, key))
19076 JSON_THROW(std::out_of_range(
"key not found"));
19081 for (
auto it = this->begin(); it != this->end(); ++it)
19083 if (m_compare(it->first, key))
19086 for (
auto next = it; ++next != this->end(); ++it)
19091 Container::pop_back();
19102 for (
auto it = this->begin(); it != this->end(); ++it)
19104 if (m_compare(it->first, key))
19107 for (
auto next = it; ++next != this->end(); ++it)
19112 Container::pop_back();
19121 return erase(pos, std::next(pos));
19131 const auto elements_affected = std::distance(first, last);
19132 const auto offset = std::distance(Container::begin(), first);
19154 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
19157 new (&*it)
value_type{ std::move(*std::next(it, elements_affected)) };
19165 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
19174 return Container::begin() + offset;
19179 for (
auto it = this->begin(); it != this->end(); ++it)
19181 if (m_compare(it->first, key))
19193 for (
auto it = this->begin(); it != this->end(); ++it)
19195 if (m_compare(it->first, key))
19205 for (
auto it = this->begin(); it != this->end(); ++it)
19207 if (m_compare(it->first, key))
19212 return Container::end();
19219 for (
auto it = this->begin(); it != this->end(); ++it)
19221 if (m_compare(it->first, key))
19226 return Container::end();
19231 for (
auto it = this->begin(); it != this->end(); ++it)
19233 if (m_compare(it->first, key))
19238 return Container::end();
19243 return emplace(value.first, std::move(value.second));
19248 for (
auto it = this->begin(); it != this->end(); ++it)
19250 if (m_compare(it->first, value.first))
19252 return { it,
false };
19255 Container::push_back(value);
19256 return { --this->end(),
true };
19259 template<
typename InputIt>
19260 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
19261 std::input_iterator_tag>::value>::type;
19263 template<
typename InputIt,
typename = require_input_iter<InputIt>>
19266 for (
auto it = first; it != last; ++it)
19279#if defined(JSON_HAS_CPP_17)
19281#include <string_view>
19311 :
public ::nlohmann::detail::json_base_class<CustomBaseClass>
19317 friend class ::nlohmann::json_pointer;
19321 template<
typename BasicJsonType,
typename InputType>
19322 friend class ::nlohmann::detail::parser;
19323 friend ::nlohmann::detail::serializer<basic_json>;
19324 template<
typename BasicJsonType>
19325 friend class ::nlohmann::detail::iter_impl;
19326 template<
typename BasicJsonType,
typename CharType>
19327 friend class ::nlohmann::detail::binary_writer;
19328 template<
typename BasicJsonType,
typename InputType,
typename SAX>
19329 friend class ::nlohmann::detail::binary_reader;
19330 template<
typename BasicJsonType>
19331 friend class ::nlohmann::detail::json_sax_dom_parser;
19332 template<
typename BasicJsonType>
19333 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
19334 friend class ::nlohmann::detail::exception;
19338 using json_base_class_t = ::nlohmann::detail::json_base_class<CustomBaseClass>;
19342 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
19344 template<
typename InputAdapterType>
19345 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
19346 InputAdapterType adapter,
19348 const bool allow_exceptions =
true,
19349 const bool ignore_comments =
false
19352 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
19353 std::move(cb), allow_exceptions, ignore_comments);
19357 using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
19358 template<
typename BasicJsonType>
19359 using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>;
19360 template<
typename BasicJsonType>
19361 using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>;
19362 template<
typename Iterator>
19363 using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>;
19364 template<
typename Base>
using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>;
19366 template<
typename CharType>
19367 using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
19369 template<
typename InputType>
19370 using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>;
19371 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
19374 using serializer = ::nlohmann::detail::serializer<basic_json>;
19380 template<
typename T,
typename SFINAE>
19437 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
19439 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
19467 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
19468 result[
"name"] =
"JSON for Modern C++";
19469 result[
"url"] =
"https://github.com/nlohmann/json";
19470 result[
"version"][
"string"] =
19479 result[
"platform"] =
"win32";
19480#elif defined __linux__
19481 result[
"platform"] =
"linux";
19482#elif defined __APPLE__
19483 result[
"platform"] =
"apple";
19484#elif defined __unix__
19485 result[
"platform"] =
"unix";
19487 result[
"platform"] =
"unknown";
19490#if defined(__ICC) || defined(__INTEL_COMPILER)
19491 result[
"compiler"] = { {
"family",
"icc"}, {
"version", __INTEL_COMPILER} };
19492#elif defined(__clang__)
19493 result[
"compiler"] = { {
"family",
"clang"}, {
"version", __clang_version__} };
19494#elif defined(__GNUC__) || defined(__GNUG__)
19495 result[
"compiler"] = { {
"family",
"gcc"}, {
"version",
detail::concat(
19496 std::to_string(__GNUC__),
'.',
19497 std::to_string(__GNUC_MINOR__),
'.',
19498 std::to_string(__GNUC_PATCHLEVEL__))
19501#elif defined(__HP_cc) || defined(__HP_aCC)
19502 result[
"compiler"] =
"hp"
19503#elif defined(__IBMCPP__)
19504 result[
"compiler"] = { {
"family",
"ilecpp"}, {
"version", __IBMCPP__} };
19505#elif defined(_MSC_VER)
19506 result[
"compiler"] = { {
"family",
"msvc"}, {
"version", _MSC_VER} };
19507#elif defined(__PGI)
19508 result[
"compiler"] = { {
"family",
"pgcpp"}, {
"version", __PGI} };
19509#elif defined(__SUNPRO_CC)
19510 result[
"compiler"] = { {
"family",
"sunpro"}, {
"version", __SUNPRO_CC} };
19512 result[
"compiler"] = { {
"family",
"unknown"}, {
"version",
"unknown"} };
19516#if defined(_MSVC_LANG)
19517 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
19518#elif defined(__cplusplus)
19519 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
19521 result[
"compiler"][
"c++"] =
"unknown";
19540#if defined(JSON_HAS_CPP_14)
19553 AllocatorType<std::pair<
const StringType,
19558 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
19582 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
19593 template<
typename T,
typename... Args>
19595 static T* create(Args&& ... args)
19597 AllocatorType<T> alloc;
19598 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
19600 auto deleter = [&](T* obj)
19602 AllocatorTraits::deallocate(alloc, obj, 1);
19604 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
19605 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
19607 return obj.release();
19660 json_value() =
default;
19662 json_value(
boolean_t v) noexcept : boolean(v) {}
19674 case value_t::object:
19676 object = create<object_t>();
19680 case value_t::array:
19682 array = create<array_t>();
19686 case value_t::string:
19688 string = create<string_t>(
"");
19692 case value_t::binary:
19694 binary = create<binary_t>();
19698 case value_t::boolean:
19700 boolean =
static_cast<boolean_t>(
false);
19704 case value_t::number_integer:
19710 case value_t::number_unsigned:
19716 case value_t::number_float:
19722 case value_t::null:
19728 case value_t::discarded:
19774 (t == value_t::object &&
object ==
nullptr) ||
19775 (t == value_t::array && array ==
nullptr) ||
19776 (t == value_t::string &&
string ==
nullptr) ||
19777 (t == value_t::binary && binary ==
nullptr)
19783 if (t == value_t::array || t == value_t::object)
19786 std::vector<basic_json> stack;
19789 if (t == value_t::array)
19791 stack.reserve(
array->size());
19792 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
19797 for (
auto&& it : *
object)
19799 stack.push_back(std::move(it.second));
19803 while (!stack.empty())
19806 basic_json current_item(std::move(stack.back()));
19811 if (current_item.is_array())
19813 std::move(current_item.m_data.m_value.array->begin(), current_item.m_data.m_value.array->end(), std::back_inserter(stack));
19815 current_item.m_data.m_value.array->clear();
19817 else if (current_item.is_object())
19819 for (
auto&& it : *current_item.m_data.m_value.object)
19821 stack.push_back(std::move(it.second));
19824 current_item.m_data.m_value.object->clear();
19834 case value_t::object:
19836 AllocatorType<object_t> alloc;
19837 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
19838 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
19842 case value_t::array:
19844 AllocatorType<array_t> alloc;
19845 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
19846 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
19850 case value_t::string:
19852 AllocatorType<string_t> alloc;
19853 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
19854 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
19858 case value_t::binary:
19860 AllocatorType<binary_t> alloc;
19861 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
19862 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
19866 case value_t::null:
19867 case value_t::boolean:
19868 case value_t::number_integer:
19869 case value_t::number_unsigned:
19870 case value_t::number_float:
19871 case value_t::discarded:
19899 void assert_invariant(
bool check_parents =
true) const noexcept
19906#if JSON_DIAGNOSTICS
19912 return j.m_parent ==
this;
19917 static_cast<void>(check_parents);
19922#if JSON_DIAGNOSTICS
19925 case value_t::array:
19927 for (
auto& element : *
m_data.m_value.array)
19929 element.m_parent =
this;
19934 case value_t::object:
19936 for (
auto& element : *
m_data.m_value.object)
19938 element.second.m_parent =
this;
19943 case value_t::null:
19944 case value_t::string:
19945 case value_t::boolean:
19946 case value_t::number_integer:
19947 case value_t::number_unsigned:
19948 case value_t::number_float:
19949 case value_t::binary:
19950 case value_t::discarded:
19957 iterator set_parents(
iterator it,
typename iterator::difference_type count_set_parents)
19959#if JSON_DIAGNOSTICS
19960 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
19962 (it + i)->m_parent =
this;
19965 static_cast<void>(count_set_parents);
19970 reference set_parent(
reference j, std::size_t old_capacity =
static_cast<std::size_t
>(-1))
19972#if JSON_DIAGNOSTICS
19973 if (old_capacity !=
static_cast<std::size_t
>(-1))
19987#ifdef JSON_HEDLEY_MSVC_VERSION
19988#pragma warning(push )
19989#pragma warning(disable : 4127)
19996#ifdef JSON_HEDLEY_MSVC_VERSION
19997#pragma warning( pop )
20002 static_cast<void>(j);
20003 static_cast<void>(old_capacity);
20035 assert_invariant();
20043 assert_invariant();
20048 template <
typename CompatibleType,
20053 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
20054 std::forward<CompatibleType>(val))))
20056 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
20058 assert_invariant();
20063 template <
typename BasicJsonType,
20068 using other_boolean_t =
typename BasicJsonType::boolean_t;
20069 using other_number_float_t =
typename BasicJsonType::number_float_t;
20070 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20071 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20072 using other_string_t =
typename BasicJsonType::string_t;
20073 using other_object_t =
typename BasicJsonType::object_t;
20074 using other_array_t =
typename BasicJsonType::array_t;
20075 using other_binary_t =
typename BasicJsonType::binary_t;
20077 switch (val.type())
20079 case value_t::boolean:
20080 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
20082 case value_t::number_float:
20083 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
20085 case value_t::number_integer:
20086 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
20088 case value_t::number_unsigned:
20089 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
20091 case value_t::string:
20092 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
20094 case value_t::object:
20095 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
20097 case value_t::array:
20098 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
20100 case value_t::binary:
20101 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
20103 case value_t::null:
20106 case value_t::discarded:
20107 m_data.m_type = value_t::discarded;
20114 assert_invariant();
20120 bool type_deduction =
true,
20121 value_t manual_type = value_t::array)
20125 bool is_an_object = std::all_of(init.begin(), init.end(),
20128 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
20132 if (!type_deduction)
20135 if (manual_type == value_t::array)
20137 is_an_object =
false;
20150 m_data.m_type = value_t::object;
20151 m_data.m_value = value_t::object;
20153 for (
auto& element_ref : init)
20156 m_data.m_value.object->emplace(
20157 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
20158 std::move((*element.m_data.m_value.array)[1]));
20164 m_data.m_type = value_t::array;
20165 m_data.m_value.array = create<array_t>(init.begin(), init.end());
20169 assert_invariant();
20178 res.m_data.m_type = value_t::binary;
20179 res.m_data.m_value = init;
20186 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
20189 res.m_data.m_type = value_t::binary;
20190 res.m_data.m_value =
binary_t(init, subtype);
20200 res.m_data.m_type = value_t::binary;
20201 res.m_data.m_value = std::move(init);
20208 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
20211 res.m_data.m_type = value_t::binary;
20212 res.m_data.m_value =
binary_t(std::move(init), subtype);
20221 return basic_json(init,
false, value_t::array);
20229 return basic_json(init,
false, value_t::object);
20238 assert_invariant();
20243 template <
class InputIT,
typename std::enable_if <
20244 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
20245 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
20258 m_data.m_type = first.m_object->m_data.m_type;
20263 case value_t::boolean:
20264 case value_t::number_float:
20265 case value_t::number_integer:
20266 case value_t::number_unsigned:
20267 case value_t::string:
20270 || !last.m_it.primitive_iterator.is_end()))
20277 case value_t::null:
20278 case value_t::object:
20279 case value_t::array:
20280 case value_t::binary:
20281 case value_t::discarded:
20288 case value_t::number_integer:
20290 m_data.m_value.number_integer = first.m_object->m_data.m_value.number_integer;
20294 case value_t::number_unsigned:
20296 m_data.m_value.number_unsigned = first.m_object->m_data.m_value.number_unsigned;
20300 case value_t::number_float:
20302 m_data.m_value.number_float = first.m_object->m_data.m_value.number_float;
20306 case value_t::boolean:
20308 m_data.m_value.boolean = first.m_object->m_data.m_value.boolean;
20312 case value_t::string:
20314 m_data.m_value = *first.m_object->m_data.m_value.string;
20318 case value_t::object:
20320 m_data.m_value.object = create<object_t>(first.m_it.object_iterator,
20321 last.m_it.object_iterator);
20325 case value_t::array:
20327 m_data.m_value.array = create<array_t>(first.m_it.array_iterator,
20328 last.m_it.array_iterator);
20332 case value_t::binary:
20334 m_data.m_value = *first.m_object->m_data.m_value.binary;
20338 case value_t::null:
20339 case value_t::discarded:
20345 assert_invariant();
20353 template<
typename JsonRef,
20355 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
20361 : json_base_class_t(other)
20365 other.assert_invariant();
20369 case value_t::object:
20375 case value_t::array:
20381 case value_t::string:
20387 case value_t::boolean:
20393 case value_t::number_integer:
20399 case value_t::number_unsigned:
20401 m_data.m_value = other.
m_data.m_value.number_unsigned;
20405 case value_t::number_float:
20411 case value_t::binary:
20417 case value_t::null:
20418 case value_t::discarded:
20424 assert_invariant();
20430 : json_base_class_t(std::move(other)),
20431 m_data(std::move(other.m_data))
20434 other.assert_invariant(
false);
20437 other.m_data.m_type = value_t::null;
20438 other.m_data.m_value = {};
20441 assert_invariant();
20447 std::is_nothrow_move_constructible<value_t>::value&&
20448 std::is_nothrow_move_assignable<value_t>::value&&
20449 std::is_nothrow_move_constructible<json_value>::value&&
20450 std::is_nothrow_move_assignable<json_value>::value&&
20451 std::is_nothrow_move_assignable<json_base_class_t>::value
20455 other.assert_invariant();
20460 json_base_class_t::operator=(std::move(other));
20463 assert_invariant();
20471 assert_invariant(
false);
20488 const char indent_char =
' ',
20489 const bool ensure_ascii =
false,
20497 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
20501 s.dump(*
this,
false, ensure_ascii, 0);
20532 return m_data.m_type == value_t::null;
20539 return m_data.m_type == value_t::boolean;
20553 return m_data.m_type == value_t::number_integer ||
m_data.m_type == value_t::number_unsigned;
20560 return m_data.m_type == value_t::number_unsigned;
20567 return m_data.m_type == value_t::number_float;
20574 return m_data.m_type == value_t::object;
20581 return m_data.m_type == value_t::array;
20588 return m_data.m_type == value_t::string;
20595 return m_data.m_type == value_t::binary;
20602 return m_data.m_type == value_t::discarded;
20624 return m_data.m_value.boolean;
20649 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
20737 template<
typename ReferenceType,
typename ThisType>
20738 static ReferenceType get_ref_impl(ThisType& obj)
20741 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
20758 template<
typename PointerType,
typename std::enable_if<
20759 std::is_pointer<PointerType>::value,
int>
::type = 0>
20760 auto get_ptr() noexcept -> decltype(
std::declval<basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
20763 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20768 template <
typename PointerType,
typename std::enable_if <
20769 std::is_pointer<PointerType>::value&&
20770 std::is_const<typename std::remove_pointer<PointerType>::type>
::value,
int >
::type = 0 >
20771 constexpr auto get_ptr() const noexcept -> decltype(
std::declval<const basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
20774 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20816 template <
typename ValueType,
20822 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
20824 auto ret = ValueType();
20825 JSONSerializer<ValueType>::from_json(*
this, ret);
20859 template <
typename ValueType,
20864 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
20866 return JSONSerializer<ValueType>::from_json(*
this);
20884 template <
typename BasicJsonType,
20907 template<
typename BasicJsonType,
20909 std::is_same<BasicJsonType, basic_json_t>::value,
20920 template<
typename PointerType,
20922 std::is_pointer<PointerType>::value,
20925 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
20928 return get_ptr<PointerType>();
20955 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
20956#if defined(JSON_HAS_CPP_14)
20960 noexcept(
std::declval<const basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
20966 static_assert(!std::is_reference<ValueTypeCV>::value,
20967 "get() cannot be used with reference types, you might want to use get_ref()");
20998 template<
typename PointerType,
typename std::enable_if<
20999 std::is_pointer<PointerType>::value,
int>
::type = 0>
21000 auto get() noexcept -> decltype(
std::declval<basic_json_t&>().template
get_ptr<PointerType>())
21003 return get_ptr<PointerType>();
21008 template <
typename ValueType,
21013 ValueType&
get_to(ValueType& v)
const noexcept(
noexcept(
21014 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
21016 JSONSerializer<ValueType>::from_json(*
this, v);
21022 template<
typename ValueType,
21033 typename T, std::size_t N,
21034 typename Array = T(&)[N],
21038 noexcept(
noexcept(JSONSerializer<Array>::from_json(
21039 std::declval<const basic_json_t&>(), v)))
21041 JSONSerializer<Array>::from_json(*
this, v);
21047 template<
typename ReferenceType,
typename std::enable_if<
21048 std::is_reference<ReferenceType>::value,
int>
::type = 0>
21052 return get_ref_impl<ReferenceType>(*
this);
21057 template <
typename ReferenceType,
typename std::enable_if <
21058 std::is_reference<ReferenceType>::value&&
21059 std::is_const<typename std::remove_reference<ReferenceType>::type>
::value,
int >
::type = 0 >
21063 return get_ref_impl<ReferenceType>(*
this);
21095 template <
typename ValueType,
typename std::enable_if <
21103#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
21106#if defined(JSON_HAS_CPP_17)
21114 return get<ValueType>();
21126 return *get_ptr<binary_t*>();
21138 return *get_ptr<const binary_t*>();
21161 return set_parent(
m_data.m_value.array->at(idx));
21184 return m_data.m_value.array->at(idx);
21208 auto it =
m_data.m_value.object->find(key);
21209 if (it ==
m_data.m_value.object->end())
21213 return set_parent(it->second);
21228 auto it =
m_data.m_value.object->find(std::forward<KeyType>(key));
21229 if (it ==
m_data.m_value.object->end())
21233 return set_parent(it->second);
21246 auto it =
m_data.m_value.object->find(key);
21247 if (it ==
m_data.m_value.object->end())
21266 auto it =
m_data.m_value.object->find(std::forward<KeyType>(key));
21267 if (it ==
m_data.m_value.object->end())
21281 m_data.m_type = value_t::array;
21282 m_data.m_value.array = create<array_t>();
21283 assert_invariant();
21290 if (idx >=
m_data.m_value.array->size())
21292#if JSON_DIAGNOSTICS
21294 const auto old_size =
m_data.m_value.array->size();
21295 const auto old_capacity =
m_data.m_value.array->capacity();
21297 m_data.m_value.array->resize(idx + 1);
21299#if JSON_DIAGNOSTICS
21308 set_parents(
begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
21311 assert_invariant();
21314 return m_data.m_value.array->operator[](idx);
21327 return m_data.m_value.array->operator[](idx);
21340 m_data.m_type = value_t::object;
21341 m_data.m_value.object = create<object_t>();
21342 assert_invariant();
21348 auto result =
m_data.m_value.object->emplace(std::move(key),
nullptr);
21349 return set_parent(result.first->second);
21362 auto it =
m_data.m_value.object->find(key);
21372 template<
typename T>
21375 return operator[](
typename object_t::key_type(key));
21378 template<
typename T>
21381 return operator[](
typename object_t::key_type(key));
21393 m_data.m_type = value_t::object;
21394 m_data.m_value.object = create<object_t>();
21395 assert_invariant();
21401 auto result =
m_data.m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
21402 return set_parent(result.first->second);
21417 auto it =
m_data.m_value.object->find(std::forward<KeyType>(key));
21426 template<
typename KeyType>
21430 template<
typename ValueType>
21431 using value_return_type = std::conditional <
21433 string_t,
typename std::decay<ValueType>::type >;
21441 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21442 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
21448 const auto it =
find(key);
21451 return it->template get<ValueType>();
21454 return default_value;
21462 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21466 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21467 ReturnType
value(
const typename object_t::key_type& key, ValueType&& default_value)
const
21473 const auto it =
find(key);
21476 return it->template get<ReturnType>();
21479 return std::forward<ValueType>(default_value);
21490 && is_comparable_with_object_key<KeyType>::value
21492 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21493 ValueType
value(KeyType&& key,
const ValueType& default_value)
const
21499 const auto it =
find(std::forward<KeyType>(key));
21502 return it->template get<ValueType>();
21505 return default_value;
21513 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
21517 && is_comparable_with_object_key<KeyType>::value
21519 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21520 ReturnType
value(KeyType&& key, ValueType&& default_value)
const
21526 const auto it =
find(std::forward<KeyType>(key));
21529 return it->template get<ReturnType>();
21532 return std::forward<ValueType>(default_value);
21542 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21551 return ptr.get_checked(
this).template get<ValueType>();
21555 return default_value;
21564 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21567 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21576 return ptr.get_checked(
this).template get<ReturnType>();
21580 return std::forward<ValueType>(default_value);
21590 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21592 ValueType
value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, const ValueType& default_value)
const
21594 return value(ptr.convert(), default_value);
21597 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
21601 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21605 return value(ptr.convert(), std::forward<ValueType>(default_value));
21643 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21644 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21653 IteratorType result =
end();
21657 case value_t::boolean:
21658 case value_t::number_float:
21659 case value_t::number_integer:
21660 case value_t::number_unsigned:
21661 case value_t::string:
21662 case value_t::binary:
21671 AllocatorType<string_t> alloc;
21672 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.string);
21673 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.string, 1);
21674 m_data.m_value.string =
nullptr;
21678 AllocatorType<binary_t> alloc;
21679 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.binary);
21680 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.binary, 1);
21681 m_data.m_value.binary =
nullptr;
21684 m_data.m_type = value_t::null;
21685 assert_invariant();
21689 case value_t::object:
21691 result.m_it.object_iterator =
m_data.m_value.object->erase(pos.m_it.object_iterator);
21695 case value_t::array:
21697 result.m_it.array_iterator =
m_data.m_value.array->erase(pos.m_it.array_iterator);
21701 case value_t::null:
21702 case value_t::discarded:
21713 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21714 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21715 IteratorType
erase(IteratorType first, IteratorType last)
21723 IteratorType result =
end();
21727 case value_t::boolean:
21728 case value_t::number_float:
21729 case value_t::number_integer:
21730 case value_t::number_unsigned:
21731 case value_t::string:
21732 case value_t::binary:
21735 || !last.m_it.primitive_iterator.is_end()))
21742 AllocatorType<string_t> alloc;
21743 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.string);
21744 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.string, 1);
21745 m_data.m_value.string =
nullptr;
21749 AllocatorType<binary_t> alloc;
21750 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.binary);
21751 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.binary, 1);
21752 m_data.m_value.binary =
nullptr;
21755 m_data.m_type = value_t::null;
21756 assert_invariant();
21760 case value_t::object:
21762 result.m_it.object_iterator =
m_data.m_value.object->erase(first.m_it.object_iterator,
21763 last.m_it.object_iterator);
21767 case value_t::array:
21769 result.m_it.array_iterator =
m_data.m_value.array->erase(first.m_it.array_iterator,
21770 last.m_it.array_iterator);
21774 case value_t::null:
21775 case value_t::discarded:
21786 size_type erase_internal(KeyType&& key)
21794 return m_data.m_value.object->erase(std::forward<KeyType>(key));
21799 size_type erase_internal(KeyType&& key)
21807 const auto it =
m_data.m_value.object->find(std::forward<KeyType>(key));
21808 if (it !=
m_data.m_value.object->end())
21810 m_data.m_value.object->erase(it);
21824 return erase_internal(key);
21833 return erase_internal(std::forward<KeyType>(key));
21870 auto result =
end();
21874 result.m_it.object_iterator =
m_data.m_value.object->find(key);
21884 auto result =
cend();
21888 result.m_it.object_iterator =
m_data.m_value.object->find(key);
21900 auto result =
end();
21904 result.m_it.object_iterator =
m_data.m_value.object->find(std::forward<KeyType>(key));
21916 auto result =
cend();
21920 result.m_it.object_iterator =
m_data.m_value.object->find(std::forward<KeyType>(key));
21941 return is_object() ?
m_data.m_value.object->count(std::forward<KeyType>(key)) : 0;
21946 bool contains(
const typename object_t::key_type& key)
const
21957 return is_object() &&
m_data.m_value.object->find(std::forward<KeyType>(key)) !=
m_data.m_value.object->end();
21964 return ptr.contains(
this);
21967 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
21971 return ptr.contains(
this);
21989 result.set_begin();
22005 result.set_begin();
22085 return ref.items();
22096 return ref.items();
22103 return iteration_proxy<iterator>(*
this);
22108 iteration_proxy<const_iterator>
items() const noexcept
22110 return iteration_proxy<const_iterator>(*
this);
22129 case value_t::null:
22135 case value_t::array:
22138 return m_data.m_value.array->empty();
22141 case value_t::object:
22144 return m_data.m_value.object->empty();
22147 case value_t::string:
22148 case value_t::boolean:
22149 case value_t::number_integer:
22150 case value_t::number_unsigned:
22151 case value_t::number_float:
22152 case value_t::binary:
22153 case value_t::discarded:
22168 case value_t::null:
22174 case value_t::array:
22177 return m_data.m_value.array->size();
22180 case value_t::object:
22183 return m_data.m_value.object->size();
22186 case value_t::string:
22187 case value_t::boolean:
22188 case value_t::number_integer:
22189 case value_t::number_unsigned:
22190 case value_t::number_float:
22191 case value_t::binary:
22192 case value_t::discarded:
22207 case value_t::array:
22210 return m_data.m_value.array->max_size();
22213 case value_t::object:
22216 return m_data.m_value.object->max_size();
22219 case value_t::null:
22220 case value_t::string:
22221 case value_t::boolean:
22222 case value_t::number_integer:
22223 case value_t::number_unsigned:
22224 case value_t::number_float:
22225 case value_t::binary:
22226 case value_t::discarded:
22251 case value_t::number_integer:
22253 m_data.m_value.number_integer = 0;
22257 case value_t::number_unsigned:
22259 m_data.m_value.number_unsigned = 0;
22263 case value_t::number_float:
22265 m_data.m_value.number_float = 0.0;
22269 case value_t::boolean:
22271 m_data.m_value.boolean =
false;
22275 case value_t::string:
22277 m_data.m_value.string->clear();
22281 case value_t::binary:
22283 m_data.m_value.binary->clear();
22287 case value_t::array:
22289 m_data.m_value.array->clear();
22293 case value_t::object:
22295 m_data.m_value.object->clear();
22299 case value_t::null:
22300 case value_t::discarded:
22319 m_data.m_type = value_t::array;
22320 m_data.m_value = value_t::array;
22321 assert_invariant();
22325 const auto old_capacity =
m_data.m_value.array->capacity();
22326 m_data.m_value.array->push_back(std::move(val));
22327 set_parent(
m_data.m_value.array->back(), old_capacity);
22352 m_data.m_type = value_t::array;
22353 m_data.m_value = value_t::array;
22354 assert_invariant();
22358 const auto old_capacity =
m_data.m_value.array->capacity();
22359 m_data.m_value.array->push_back(val);
22360 set_parent(
m_data.m_value.array->back(), old_capacity);
22384 m_data.m_type = value_t::object;
22385 m_data.m_value = value_t::object;
22386 assert_invariant();
22390 auto res =
m_data.m_value.object->insert(val);
22391 set_parent(res.first->second);
22406 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
22408 basic_json&& key = init.begin()->moved_or_copied();
22409 push_back(
typename object_t::value_type(
22410 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
22428 template<
class... Args>
22440 m_data.m_type = value_t::array;
22441 m_data.m_value = value_t::array;
22442 assert_invariant();
22446 const auto old_capacity =
m_data.m_value.array->capacity();
22447 m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
22448 return set_parent(
m_data.m_value.array->back(), old_capacity);
22453 template<
class... Args>
22465 m_data.m_type = value_t::object;
22466 m_data.m_value = value_t::object;
22467 assert_invariant();
22471 auto res =
m_data.m_value.object->emplace(std::forward<Args>(args)...);
22472 set_parent(res.first->second);
22476 it.m_it.object_iterator = res.first;
22479 return { it, res.second };
22485 template<
typename... Args>
22491 auto insert_pos = std::distance(
m_data.m_value.array->begin(), pos.m_it.array_iterator);
22492 m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
22493 result.m_it.array_iterator =
m_data.m_value.array->begin() + insert_pos;
22527 return insert(pos, val);
22578 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
22623 m_data.m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
22640 m_data.m_type = value_t::object;
22641 m_data.m_value.object = create<object_t>();
22642 assert_invariant();
22662 for (
auto it = first; it != last; ++it)
22664 if (merge_objects && it.value().is_object())
22666 auto it2 =
m_data.m_value.object->find(it.key());
22667 if (it2 !=
m_data.m_value.object->end())
22669 it2->second.update(it.value(),
true);
22673 m_data.m_value.object->operator[](it.key()) = it.value();
22674#if JSON_DIAGNOSTICS
22675 m_data.m_value.object->operator[](it.key()).m_parent =
this;
22683 std::is_nothrow_move_constructible<value_t>::value&&
22684 std::is_nothrow_move_assignable<value_t>::value&&
22685 std::is_nothrow_move_constructible<json_value>::value&&
22686 std::is_nothrow_move_assignable<json_value>::value
22693 other.set_parents();
22694 assert_invariant();
22700 std::is_nothrow_move_constructible<value_t>::value&&
22701 std::is_nothrow_move_assignable<value_t>::value&&
22702 std::is_nothrow_move_constructible<json_value>::value&&
22703 std::is_nothrow_move_assignable<json_value>::value
22775 void swap(
typename binary_t::container_type& other)
22800#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
22801 const auto lhs_type = lhs.type(); \
22802 const auto rhs_type = rhs.type(); \
22804 if (lhs_type == rhs_type) \
22806 switch (lhs_type) \
22808 case value_t::array: \
22809 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
22811 case value_t::object: \
22812 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
22814 case value_t::null: \
22815 return (null_result); \
22817 case value_t::string: \
22818 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \
22820 case value_t::boolean: \
22821 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \
22823 case value_t::number_integer: \
22824 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \
22826 case value_t::number_unsigned: \
22827 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \
22829 case value_t::number_float: \
22830 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \
22832 case value_t::binary: \
22833 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
22835 case value_t::discarded: \
22837 return (unordered_result); \
22840 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
22842 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \
22844 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
22846 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \
22848 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
22850 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \
22852 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
22854 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \
22856 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
22858 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \
22860 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
22862 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \
22864 else if(compares_unordered(lhs, rhs))\
22866 return (unordered_result);\
22869 return (default_result);
22884#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22895 return compares_unordered(*
this,
rhs,
inverse);
22899#if JSON_HAS_THREE_WAY_COMPARISON
22905#pragma GCC diagnostic push
22906#pragma GCC diagnostic ignored "-Wfloat-equal"
22911#pragma GCC diagnostic pop
22917 template<
typename ScalarType>
22918 requires std::is_scalar_v<ScalarType>
22928 if (compares_unordered(
rhs,
true))
22943 std::partial_ordering::equivalent,
22944 std::partial_ordering::unordered,
22945 lhs_type <=> rhs_type)
22950 template<
typename ScalarType>
22951 requires std::is_scalar_v<ScalarType>
22952 std::partial_ordering operator<=>(ScalarType
rhs)
const noexcept
22957#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22966 if (compares_unordered(
rhs,
true))
22970 return !(
rhs < *
this);
22975 template<
typename ScalarType>
22976 requires std::is_scalar_v<ScalarType>
22977 bool operator<=(ScalarType
rhs)
const noexcept
22987 if (compares_unordered(
rhs,
true))
22991 return !(*
this <
rhs);
22996 template<
typename ScalarType>
22997 requires std::is_scalar_v<ScalarType>
22998 bool operator>=(ScalarType
rhs)
const noexcept
23009#pragma GCC diagnostic push
23010#pragma GCC diagnostic ignored "-Wfloat-equal"
23014#pragma GCC diagnostic pop
23020 template<
typename ScalarType,
typename std::enable_if<
23021 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23029 template<
typename ScalarType,
typename std::enable_if<
23030 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23040 if (compares_unordered(lhs,
rhs,
true))
23044 return !(lhs ==
rhs);
23049 template<
typename ScalarType,
typename std::enable_if<
23050 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23058 template<
typename ScalarType,
typename std::enable_if<
23059 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23077 template<
typename ScalarType,
typename std::enable_if<
23078 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23086 template<
typename ScalarType,
typename std::enable_if<
23087 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23097 if (compares_unordered(lhs,
rhs,
true))
23101 return !(
rhs < lhs);
23106 template<
typename ScalarType,
typename std::enable_if<
23107 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23115 template<
typename ScalarType,
typename std::enable_if<
23116 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23127 if (compares_unordered(lhs,
rhs))
23131 return !(lhs <=
rhs);
23136 template<
typename ScalarType,
typename std::enable_if<
23137 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23145 template<
typename ScalarType,
typename std::enable_if<
23146 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23156 if (compares_unordered(lhs,
rhs,
true))
23160 return !(lhs <
rhs);
23165 template<
typename ScalarType,
typename std::enable_if<
23166 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23174 template<
typename ScalarType,
typename std::enable_if<
23175 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23182#undef JSON_IMPLEMENT_OPERATOR
23198 const bool pretty_print = o.width() > 0;
23199 const auto indentation = pretty_print ? o.width() : 0;
23206 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
23234 template<
typename InputType>
23238 const bool allow_exceptions =
true,
23239 const bool ignore_comments =
false)
23248 template<
typename IteratorType>
23253 const bool allow_exceptions =
true,
23254 const bool ignore_comments =
false)
23265 const bool allow_exceptions =
true,
23266 const bool ignore_comments =
false)
23269 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
23275 template<
typename InputType>
23276 static bool accept(InputType&& i,
23277 const bool ignore_comments =
false)
23284 template<
typename IteratorType>
23285 static bool accept(IteratorType first, IteratorType last,
23286 const bool ignore_comments =
false)
23294 const bool ignore_comments =
false)
23296 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
23301 template <
typename InputType,
typename SAX>
23305 const
bool strict = true,
23306 const
bool ignore_comments = false)
23309 return format == input_format_t::json
23310 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23316 template<
class IteratorType,
class SAX>
23318 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
23320 const
bool strict = true,
23321 const
bool ignore_comments = false)
23324 return format == input_format_t::json
23325 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23334 template <
typename SAX>
23339 const
bool strict = true,
23340 const
bool ignore_comments = false)
23343 return format == input_format_t::json
23345 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23383 case value_t::null:
23385 case value_t::object:
23387 case value_t::array:
23389 case value_t::string:
23391 case value_t::boolean:
23393 case value_t::binary:
23395 case value_t::discarded:
23396 return "discarded";
23397 case value_t::number_integer:
23398 case value_t::number_unsigned:
23399 case value_t::number_float:
23414 value_t m_type = value_t::null;
23427 m_value.array = create<array_t>(cnt, val);
23444#if JSON_DIAGNOSTICS
23461 std::vector<std::uint8_t> result;
23470 binary_writer<std::uint8_t>(o).write_cbor(j);
23477 binary_writer<char>(o).write_cbor(j);
23484 std::vector<std::uint8_t> result;
23493 binary_writer<std::uint8_t>(o).write_msgpack(j);
23500 binary_writer<char>(o).write_msgpack(j);
23506 const bool use_size =
false,
23507 const bool use_type =
false)
23509 std::vector<std::uint8_t> result;
23510 to_ubjson(j, result, use_size, use_type);
23517 const bool use_size =
false,
const bool use_type =
false)
23519 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
23525 const bool use_size =
false,
const bool use_type =
false)
23527 binary_writer<char>(o).write_ubjson(j, use_size, use_type);
23533 const bool use_size =
false,
23534 const bool use_type =
false)
23536 std::vector<std::uint8_t> result;
23537 to_bjdata(j, result, use_size, use_type);
23544 const bool use_size =
false,
const bool use_type =
false)
23546 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type,
true,
true);
23552 const bool use_size =
false,
const bool use_type =
false)
23554 binary_writer<char>(o).write_ubjson(j, use_size, use_type,
true,
true);
23561 std::vector<std::uint8_t> result;
23570 binary_writer<std::uint8_t>(o).write_bson(j);
23577 binary_writer<char>(o).write_bson(j);
23582 template<
typename InputType>
23585 const bool strict =
true,
23586 const bool allow_exceptions =
true,
23592 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23593 return res ? result :
basic_json(value_t::discarded);
23598 template<
typename IteratorType>
23601 const bool strict =
true,
23602 const bool allow_exceptions =
true,
23608 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23609 return res ? result :
basic_json(value_t::discarded);
23612 template<
typename T>
23616 const
bool strict = true,
23617 const
bool allow_exceptions = true,
23620 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
23627 const
bool strict = true,
23628 const
bool allow_exceptions = true,
23635 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23636 return res ? result :
basic_json(value_t::discarded);
23641 template<
typename InputType>
23644 const bool strict =
true,
23645 const bool allow_exceptions =
true)
23650 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23651 return res ? result :
basic_json(value_t::discarded);
23656 template<
typename IteratorType>
23659 const bool strict =
true,
23660 const bool allow_exceptions =
true)
23665 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23666 return res ? result :
basic_json(value_t::discarded);
23669 template<
typename T>
23673 const
bool strict = true,
23674 const
bool allow_exceptions = true)
23676 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
23682 const
bool strict = true,
23683 const
bool allow_exceptions = true)
23689 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23690 return res ? result :
basic_json(value_t::discarded);
23695 template<
typename InputType>
23698 const bool strict =
true,
23699 const bool allow_exceptions =
true)
23704 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23705 return res ? result :
basic_json(value_t::discarded);
23710 template<
typename IteratorType>
23713 const bool strict =
true,
23714 const bool allow_exceptions =
true)
23719 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23720 return res ? result :
basic_json(value_t::discarded);
23723 template<
typename T>
23727 const
bool strict = true,
23728 const
bool allow_exceptions = true)
23730 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
23736 const
bool strict = true,
23737 const
bool allow_exceptions = true)
23743 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23744 return res ? result :
basic_json(value_t::discarded);
23750 template<
typename InputType>
23753 const bool strict =
true,
23754 const bool allow_exceptions =
true)
23759 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23760 return res ? result :
basic_json(value_t::discarded);
23765 template<
typename IteratorType>
23768 const bool strict =
true,
23769 const bool allow_exceptions =
true)
23774 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23775 return res ? result :
basic_json(value_t::discarded);
23780 template<
typename InputType>
23783 const bool strict =
true,
23784 const bool allow_exceptions =
true)
23789 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23790 return res ? result :
basic_json(value_t::discarded);
23795 template<
typename IteratorType>
23798 const bool strict =
true,
23799 const bool allow_exceptions =
true)
23804 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23805 return res ? result :
basic_json(value_t::discarded);
23808 template<
typename T>
23812 const
bool strict = true,
23813 const
bool allow_exceptions = true)
23815 return from_bson(ptr, ptr + len, strict, allow_exceptions);
23821 const
bool strict = true,
23822 const
bool allow_exceptions = true)
23828 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23829 return res ? result :
basic_json(value_t::discarded);
23844 return ptr.get_unchecked(
this);
23847 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23851 return ptr.get_unchecked(
this);
23858 return ptr.get_unchecked(
this);
23861 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23865 return ptr.get_unchecked(
this);
23872 return ptr.get_checked(
this);
23875 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23879 return ptr.get_checked(
this);
23886 return ptr.get_checked(
this);
23889 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23893 return ptr.get_checked(
this);
23901 json_pointer::flatten(
"", *
this, result);
23909 return json_pointer::unflatten(*
this);
23927 enum class patch_operations { add, remove, replace, move, copy, test, invalid };
23929 const auto get_op = [](
const std::string& op)
23933 return patch_operations::add;
23935 if (op ==
"remove")
23937 return patch_operations::remove;
23939 if (op ==
"replace")
23941 return patch_operations::replace;
23945 return patch_operations::move;
23949 return patch_operations::copy;
23953 return patch_operations::test;
23956 return patch_operations::invalid;
23971 if (top_pointer != ptr)
23973 result.
at(top_pointer);
23977 const auto last_path = ptr.
back();
23982 switch (parent.
m_data.m_type)
23984 case value_t::null:
23985 case value_t::object:
23988 parent[last_path] = val;
23992 case value_t::array:
23994 if (last_path ==
"-")
24001 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
24015 case value_t::string:
24016 case value_t::boolean:
24017 case value_t::number_integer:
24018 case value_t::number_unsigned:
24019 case value_t::number_float:
24020 case value_t::binary:
24021 case value_t::discarded:
24028 const auto operation_remove = [
this, &result](
json_pointer& ptr)
24031 const auto last_path = ptr.
back();
24039 auto it = parent.
find(last_path);
24052 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
24063 for (
const auto& val : json_patch)
24066 const auto get_value = [&val](
const std::string& op,
24067 const std::string& member,
24071 auto it = val.
m_data.m_value.object->find(member);
24074 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
24101 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
24102 const auto path = get_value(op,
"path",
true).template get<std::string>();
24105 switch (get_op(op))
24107 case patch_operations::add:
24109 operation_add(ptr, get_value(
"add",
"value",
false));
24113 case patch_operations::remove:
24115 operation_remove(ptr);
24119 case patch_operations::replace:
24122 result.
at(ptr) = get_value(
"replace",
"value",
false);
24126 case patch_operations::move:
24128 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
24138 operation_remove(from_ptr);
24139 operation_add(ptr, v);
24143 case patch_operations::copy:
24145 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
24154 operation_add(ptr, v);
24158 case patch_operations::test:
24160 bool success =
false;
24165 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
24181 case patch_operations::invalid:
24205 const std::string& path =
"")
24211 if (source == target)
24216 if (source.
type() != target.
type())
24221 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24226 switch (source.
type())
24228 case value_t::array:
24232 while (i < source.
size() && i < target.
size())
24235 auto temp_diff =
diff(source[i], target[i],
detail::concat(path,
'/', std::to_string(i)));
24236 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
24245 while (i < source.
size())
24258 while (i < target.
size())
24264 {
"value", target[i]}
24272 case value_t::object:
24275 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
24280 if (target.
find(it.key()) != target.
end())
24283 auto temp_diff =
diff(it.value(), target[it.key()], path_key);
24284 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
24291 {
"op",
"remove"}, {
"path", path_key}
24297 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
24299 if (source.
find(it.key()) == source.
end())
24305 {
"op",
"add"}, {
"path", path_key},
24306 {
"value", it.value()}
24314 case value_t::null:
24315 case value_t::string:
24316 case value_t::boolean:
24317 case value_t::number_integer:
24318 case value_t::number_unsigned:
24319 case value_t::number_float:
24320 case value_t::binary:
24321 case value_t::discarded:
24327 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24354 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
24356 if (it.value().is_null())
24368 *
this = apply_patch;
24385 inline namespace json_literals
24391 inline nlohmann::
json operator "" _json(const
char* s,
std::
size_t n)
24393 return nlohmann::json::parse(s, s + n);
24401 return nlohmann::json::json_pointer(std::string(s, n));
24420 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
24422 return nlohmann::detail::hash(j);
24428 struct less< ::nlohmann::detail::value_t>
24435 ::nlohmann::detail::value_t rhs)
const noexcept
24437#if JSON_HAS_THREE_WAY_COMPARISON
24438 return std::is_lt(lhs <=> rhs);
24440 return ::nlohmann::detail::operator<(lhs, rhs);
24446#ifndef JSON_HAS_CPP_20
24451 inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
24452 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
24453 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
24462#if JSON_USE_GLOBAL_UDLS
24463using nlohmann::literals::json_literals::operator
"" _json;
24464using nlohmann::literals::json_literals::operator
"" _json_pointer;
24479#if defined(__clang__)
24480#pragma clang diagnostic pop
24485#undef JSON_INTERNAL_CATCH
24487#undef JSON_PRIVATE_UNLESS_TESTED
24488#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
24489#undef NLOHMANN_BASIC_JSON_TPL
24490#undef JSON_EXPLICIT
24491#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
24492#undef JSON_INLINE_VARIABLE
24493#undef JSON_NO_UNIQUE_ADDRESS
24494#undef JSON_DISABLE_ENUM_SERIALIZATION
24495#undef JSON_USE_GLOBAL_UDLS
24497#ifndef JSON_TEST_KEEP_MACROS
24500#undef JSON_HAS_CPP_11
24501#undef JSON_HAS_CPP_14
24502#undef JSON_HAS_CPP_17
24503#undef JSON_HAS_CPP_20
24504#undef JSON_HAS_FILESYSTEM
24505#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
24506#undef JSON_HAS_THREE_WAY_COMPARISON
24507#undef JSON_HAS_RANGES
24508#undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
24522#undef JSON_HEDLEY_ALWAYS_INLINE
24523#undef JSON_HEDLEY_ARM_VERSION
24524#undef JSON_HEDLEY_ARM_VERSION_CHECK
24525#undef JSON_HEDLEY_ARRAY_PARAM
24526#undef JSON_HEDLEY_ASSUME
24527#undef JSON_HEDLEY_BEGIN_C_DECLS
24528#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
24529#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
24530#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
24531#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
24532#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
24533#undef JSON_HEDLEY_CLANG_HAS_FEATURE
24534#undef JSON_HEDLEY_CLANG_HAS_WARNING
24535#undef JSON_HEDLEY_COMPCERT_VERSION
24536#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
24537#undef JSON_HEDLEY_CONCAT
24538#undef JSON_HEDLEY_CONCAT3
24539#undef JSON_HEDLEY_CONCAT3_EX
24540#undef JSON_HEDLEY_CONCAT_EX
24541#undef JSON_HEDLEY_CONST
24542#undef JSON_HEDLEY_CONSTEXPR
24543#undef JSON_HEDLEY_CONST_CAST
24544#undef JSON_HEDLEY_CPP_CAST
24545#undef JSON_HEDLEY_CRAY_VERSION
24546#undef JSON_HEDLEY_CRAY_VERSION_CHECK
24547#undef JSON_HEDLEY_C_DECL
24548#undef JSON_HEDLEY_DEPRECATED
24549#undef JSON_HEDLEY_DEPRECATED_FOR
24550#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
24551#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
24552#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
24553#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
24554#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
24555#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
24556#undef JSON_HEDLEY_DIAGNOSTIC_POP
24557#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
24558#undef JSON_HEDLEY_DMC_VERSION
24559#undef JSON_HEDLEY_DMC_VERSION_CHECK
24560#undef JSON_HEDLEY_EMPTY_BASES
24561#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
24562#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
24563#undef JSON_HEDLEY_END_C_DECLS
24564#undef JSON_HEDLEY_FLAGS
24565#undef JSON_HEDLEY_FLAGS_CAST
24566#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
24567#undef JSON_HEDLEY_GCC_HAS_BUILTIN
24568#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
24569#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
24570#undef JSON_HEDLEY_GCC_HAS_EXTENSION
24571#undef JSON_HEDLEY_GCC_HAS_FEATURE
24572#undef JSON_HEDLEY_GCC_HAS_WARNING
24573#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
24574#undef JSON_HEDLEY_GCC_VERSION
24575#undef JSON_HEDLEY_GCC_VERSION_CHECK
24576#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
24577#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
24578#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
24579#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
24580#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
24581#undef JSON_HEDLEY_GNUC_HAS_FEATURE
24582#undef JSON_HEDLEY_GNUC_HAS_WARNING
24583#undef JSON_HEDLEY_GNUC_VERSION
24584#undef JSON_HEDLEY_GNUC_VERSION_CHECK
24585#undef JSON_HEDLEY_HAS_ATTRIBUTE
24586#undef JSON_HEDLEY_HAS_BUILTIN
24587#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
24588#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
24589#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
24590#undef JSON_HEDLEY_HAS_EXTENSION
24591#undef JSON_HEDLEY_HAS_FEATURE
24592#undef JSON_HEDLEY_HAS_WARNING
24593#undef JSON_HEDLEY_IAR_VERSION
24594#undef JSON_HEDLEY_IAR_VERSION_CHECK
24595#undef JSON_HEDLEY_IBM_VERSION
24596#undef JSON_HEDLEY_IBM_VERSION_CHECK
24597#undef JSON_HEDLEY_IMPORT
24598#undef JSON_HEDLEY_INLINE
24599#undef JSON_HEDLEY_INTEL_CL_VERSION
24600#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
24601#undef JSON_HEDLEY_INTEL_VERSION
24602#undef JSON_HEDLEY_INTEL_VERSION_CHECK
24603#undef JSON_HEDLEY_IS_CONSTANT
24604#undef JSON_HEDLEY_IS_CONSTEXPR_
24605#undef JSON_HEDLEY_LIKELY
24606#undef JSON_HEDLEY_MALLOC
24607#undef JSON_HEDLEY_MCST_LCC_VERSION
24608#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
24609#undef JSON_HEDLEY_MESSAGE
24610#undef JSON_HEDLEY_MSVC_VERSION
24611#undef JSON_HEDLEY_MSVC_VERSION_CHECK
24612#undef JSON_HEDLEY_NEVER_INLINE
24613#undef JSON_HEDLEY_NON_NULL
24614#undef JSON_HEDLEY_NO_ESCAPE
24615#undef JSON_HEDLEY_NO_RETURN
24616#undef JSON_HEDLEY_NO_THROW
24617#undef JSON_HEDLEY_NULL
24618#undef JSON_HEDLEY_PELLES_VERSION
24619#undef JSON_HEDLEY_PELLES_VERSION_CHECK
24620#undef JSON_HEDLEY_PGI_VERSION
24621#undef JSON_HEDLEY_PGI_VERSION_CHECK
24622#undef JSON_HEDLEY_PREDICT
24623#undef JSON_HEDLEY_PRINTF_FORMAT
24624#undef JSON_HEDLEY_PRIVATE
24625#undef JSON_HEDLEY_PUBLIC
24626#undef JSON_HEDLEY_PURE
24627#undef JSON_HEDLEY_REINTERPRET_CAST
24628#undef JSON_HEDLEY_REQUIRE
24629#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
24630#undef JSON_HEDLEY_REQUIRE_MSG
24631#undef JSON_HEDLEY_RESTRICT
24632#undef JSON_HEDLEY_RETURNS_NON_NULL
24633#undef JSON_HEDLEY_SENTINEL
24634#undef JSON_HEDLEY_STATIC_ASSERT
24635#undef JSON_HEDLEY_STATIC_CAST
24636#undef JSON_HEDLEY_STRINGIFY
24637#undef JSON_HEDLEY_STRINGIFY_EX
24638#undef JSON_HEDLEY_SUNPRO_VERSION
24639#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
24640#undef JSON_HEDLEY_TINYC_VERSION
24641#undef JSON_HEDLEY_TINYC_VERSION_CHECK
24642#undef JSON_HEDLEY_TI_ARMCL_VERSION
24643#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
24644#undef JSON_HEDLEY_TI_CL2000_VERSION
24645#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
24646#undef JSON_HEDLEY_TI_CL430_VERSION
24647#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
24648#undef JSON_HEDLEY_TI_CL6X_VERSION
24649#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
24650#undef JSON_HEDLEY_TI_CL7X_VERSION
24651#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
24652#undef JSON_HEDLEY_TI_CLPRU_VERSION
24653#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
24654#undef JSON_HEDLEY_TI_VERSION
24655#undef JSON_HEDLEY_TI_VERSION_CHECK
24656#undef JSON_HEDLEY_UNAVAILABLE
24657#undef JSON_HEDLEY_UNLIKELY
24658#undef JSON_HEDLEY_UNPREDICTABLE
24659#undef JSON_HEDLEY_UNREACHABLE
24660#undef JSON_HEDLEY_UNREACHABLE_RETURN
24661#undef JSON_HEDLEY_VERSION
24662#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
24663#undef JSON_HEDLEY_VERSION_DECODE_MINOR
24664#undef JSON_HEDLEY_VERSION_DECODE_REVISION
24665#undef JSON_HEDLEY_VERSION_ENCODE
24666#undef JSON_HEDLEY_WARNING
24667#undef JSON_HEDLEY_WARN_UNUSED_RESULT
24668#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
24669#undef JSON_HEDLEY_FALL_THROUGH
nlohmann::json json
Definition: ARX.cpp:8
a class to store JSON values
Definition: json.hpp:19312
constexpr bool is_string() const noexcept
return whether value is a string
Definition: json.hpp:20586
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition: json.hpp:21820
reference operator[](KeyType &&key)
access specified object element
Definition: json.hpp:21388
size_type size() const noexcept
returns the number of elements
Definition: json.hpp:22164
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition: json.hpp:23600
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition: json.hpp:23532
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
Definition: json.hpp:20959
const_iterator end() const noexcept
returns an iterator to one past the last element
Definition: json.hpp:22020
reference back()
access the last element
Definition: json.hpp:21624
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
Definition: json.hpp:20052
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
Definition: json.hpp:22036
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
Definition: json.hpp:24194
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
Definition: json.hpp:23379
const_reference front() const
access the first element
Definition: json.hpp:21617
constexpr bool is_array() const noexcept
return whether value is an array
Definition: json.hpp:20579
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition: json.hpp:21568
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
Definition: json.hpp:21938
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
Definition: json.hpp:19444
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition: json.hpp:23551
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
Definition: json.hpp:19387
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
Definition: json.hpp:20551
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
Definition: json.hpp:19448
data(size_type cnt, const basic_json &val)
Definition: json.hpp:23424
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition: json.hpp:23797
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition: json.hpp:23543
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.hpp:23842
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
Definition: json.hpp:19439
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.hpp:22682
std::size_t size_type
a type to represent container sizes
Definition: json.hpp:19431
constexpr bool is_structured() const noexcept
return whether type is structured
Definition: json.hpp:20523
const_reference operator[](KeyType &&key) const
access specified object element
Definition: json.hpp:21412
const value_type & const_reference
the type of an element const reference
Definition: json.hpp:19426
void swap(binary_t &other)
exchanges the values
Definition: json.hpp:22759
ReferenceType get_ref()
get a reference value (implicit)
Definition: json.hpp:21049
size_type max_size() const noexcept
returns the maximum possible number of elements
Definition: json.hpp:22203
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:22628
ReferenceType get_ref() const
get a reference value (implicit)
Definition: json.hpp:21060
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition: json.hpp:20600
JSON_PRIVATE_UNLESS_TESTED const_reference rhs
Definition: json.hpp:22877
reference operator+=(initializer_list_t init)
add an object to an object
Definition: json.hpp:22420
void push_back(basic_json &&val)
add an object to an array
Definition: json.hpp:22308
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
Definition: json.hpp:21357
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
Definition: json.hpp:22108
const_reference back() const
access the last element
Definition: json.hpp:21633
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition: json.hpp:21715
reference operator+=(const basic_json &val)
add an object to an array
Definition: json.hpp:22365
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition: json.hpp:23697
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition: json.hpp:20186
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
Definition: json.hpp:22532
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition: json.hpp:23782
static allocator_type get_allocator()
returns the allocator associated with the container
Definition: json.hpp:19455
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
Definition: json.hpp:19582
reference at(KeyType &&key)
access specified object element with bounds checking
Definition: json.hpp:21220
iterator end() noexcept
returns an iterator to one past the last element
Definition: json.hpp:22011
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition: json.hpp:20558
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:22635
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
Definition: json.hpp:23559
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
Definition: json.hpp:22043
data m_data
Definition: json.hpp:23442
void push_back(initializer_list_t init)
add an object to an object
Definition: json.hpp:22404
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
Definition: json.hpp:20019
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition: json.hpp:20227
ValueType & get_to(ValueType &v) const
Definition: json.hpp:21026
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:23498
iterator begin() noexcept
returns an iterator to the first element
Definition: json.hpp:21986
JSON_PRIVATE_UNLESS_TESTED const_reference bool inverse
Definition: json.hpp:22877
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
Definition: json.hpp:21467
const_iterator cend() const noexcept
returns an iterator to one past the last element
Definition: json.hpp:22027
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition: json.hpp:23752
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:23884
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
Definition: json.hpp:20197
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition: json.hpp:20040
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition: json.hpp:23584
basic_json flatten() const
return flattened JSON value
Definition: json.hpp:23898
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition: json.hpp:23712
size_type erase(KeyType &&key)
remove element from a JSON object given a key
Definition: json.hpp:21831
const binary_t & get_binary() const
get a binary value
Definition: json.hpp:21131
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
Definition: json.hpp:22552
void patch_inplace(const basic_json &json_patch)
applies a JSON patch in-place without copying the object
Definition: json.hpp:23923
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition: json.hpp:21520
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
Definition: json.hpp:24204
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:23856
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition: json.hpp:19558
value_type & reference
the type of an element reference
Definition: json.hpp:19424
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
Definition: json.hpp:21955
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
Definition: json.hpp:23468
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
Definition: json.hpp:23575
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
Definition: json.hpp:21868
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
Definition: json.hpp:20175
const_reference at(KeyType &&key) const
access specified object element with bounds checking
Definition: json.hpp:21258
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
Definition: json.hpp:19463
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition: json.hpp:20234
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
Definition: json.hpp:21882
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
Definition: json.hpp:23459
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition: json.hpp:21645
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
Definition: json.hpp:22505
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:19578
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
Definition: json.hpp:21442
AllocatorType< basic_json > allocator_type
the allocator type
Definition: json.hpp:19434
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
Definition: json.hpp:19437
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
Definition: json.hpp:20487
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
Definition: json.hpp:24346
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
Definition: json.hpp:21013
reference operator[](T *key)
Definition: json.hpp:21373
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:21154
iterator find(KeyType &&key)
find an element in a JSON object
Definition: json.hpp:21898
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
Definition: json.hpp:20565
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
Definition: json.hpp:22050
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:23505
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.hpp:23870
BooleanType boolean_t
a type for a boolean
Definition: json.hpp:19566
detail::value_t value_t
Definition: json.hpp:19377
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
Definition: json.hpp:19545
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:22396
const_iterator cbegin() const noexcept
returns a const iterator to the first element
Definition: json.hpp:22002
reference operator[](typename object_t::key_type key)
access specified object element
Definition: json.hpp:21335
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:20771
~basic_json() noexcept
destructor
Definition: json.hpp:20469
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
Definition: json.hpp:22071
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
Definition: json.hpp:20119
void swap(typename binary_t::container_type &other)
exchanges the values
Definition: json.hpp:22775
binary_t & get_binary()
get a binary value
Definition: json.hpp:21119
const_iterator begin() const noexcept
returns an iterator to the first element
Definition: json.hpp:21995
constexpr bool is_number() const noexcept
return whether value is a number
Definition: json.hpp:20544
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
Definition: json.hpp:22603
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition: json.hpp:23643
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition: json.hpp:21000
const_reference operator[](T *key) const
Definition: json.hpp:21379
data(const value_t v)
Definition: json.hpp:23419
reference operator[](size_type idx)
access specified array element
Definition: json.hpp:21276
basic_json(const JsonRef &ref)
Definition: json.hpp:20356
JSONSerializer< T, SFINAE > json_serializer
Definition: json.hpp:19381
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value &&std::is_nothrow_move_assignable< json_base_class_t >::value)
copy assignment
Definition: json.hpp:20446
static iteration_proxy< iterator > iterator_wrapper(reference ref) noexcept
wrapper to access iterator member functions in range-based for
Definition: json.hpp:22083
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:23524
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
Definition: json.hpp:21037
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:19570
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:20760
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition: json.hpp:21238
constexpr bool is_binary() const noexcept
return whether value is a binary array
Definition: json.hpp:20593
void swap(object_t &other)
exchanges the values
Definition: json.hpp:22727
basic_json unflatten() const
unflatten a previously flattened JSON value
Definition: json.hpp:23907
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
Definition: json.hpp:22583
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition: json.hpp:20208
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
Definition: json.hpp:22101
bool empty() const noexcept
checks whether the container is empty.
Definition: json.hpp:22125
void swap(array_t &other)
exchanges the values
Definition: json.hpp:22711
void erase(const size_type idx)
remove element from a JSON array given an index
Definition: json.hpp:21838
reference operator+=(basic_json &&val)
add an object to an array
Definition: json.hpp:22333
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
Definition: json.hpp:21962
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition: json.hpp:20509
reference emplace_back(Args &&... args)
add an object to an array
Definition: json.hpp:22429
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition: json.hpp:21543
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition: json.hpp:20219
StringType string_t
a type for a string
Definition: json.hpp:19562
friend class ::nlohmann::detail::parser
Definition: json.hpp:19322
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
Definition: json.hpp:19554
void push_back(const basic_json &val)
add an object to an array
Definition: json.hpp:22341
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
Definition: json.hpp:21493
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition: json.hpp:21200
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition: json.hpp:23767
json_value m_value
the value of the current element
Definition: json.hpp:23417
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
Definition: json.hpp:22064
constexpr bool is_boolean() const noexcept
return whether value is a boolean
Definition: json.hpp:20537
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
Definition: json.hpp:21928
reference front()
access the first element
Definition: json.hpp:21610
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition: json.hpp:20516
constexpr bool is_null() const noexcept
return whether value is null
Definition: json.hpp:20530
void clear() noexcept
clears the contents
Definition: json.hpp:22247
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:23516
JSON_PRIVATE_UNLESS_TESTED const_reference bool static SAX bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
Definition: json.hpp:23303
basic_json(basic_json &&other) noexcept
move constructor
Definition: json.hpp:20429
iter_impl< basic_json > iterator
an iterator for a basic_json container
Definition: json.hpp:19442
basic_json(const value_t v)
create an empty value with a given type
Definition: json.hpp:20032
const_reference operator[](size_type idx) const
access specified array element
Definition: json.hpp:21322
std::ptrdiff_t difference_type
a type to represent differences between iterators
Definition: json.hpp:19429
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
Definition: json.hpp:22525
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
Definition: json.hpp:22057
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
Definition: json.hpp:19574
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
Definition: json.hpp:23364
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:23482
void swap(string_t &other)
exchanges the values
Definition: json.hpp:22743
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
Definition: json.hpp:20066
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
Definition: json.hpp:19446
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.hpp:22699
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition: json.hpp:21177
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
Definition: json.hpp:19586
basic_json(const basic_json &other)
copy constructor
Definition: json.hpp:20360
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:22373
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
Definition: json.hpp:22454
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
Definition: json.hpp:23475
constexpr bool is_object() const noexcept
return whether value is an object
Definition: json.hpp:20572
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:23491
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition: json.hpp:23658
iterator insert_iterator(const_iterator pos, Args &&... args)
Helper for insertion of an iterator.
Definition: json.hpp:22486
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition: json.hpp:20246
friend std::istream & operator<<(basic_json &j, std::istream &i)
deserialize from stream
Definition: json.hpp:23357
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
Definition: json.hpp:21946
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
Definition: json.hpp:23568
const_iterator find(KeyType &&key) const
find an element in a JSON object
Definition: json.hpp:21914
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer.
Definition: json.hpp:19379
an internal type for a backed binary type
Definition: json.hpp:5825
bool operator!=(const byte_container_with_subtype &rhs) const
Definition: json.hpp:5865
byte_container_with_subtype() noexcept(noexcept(container_type()))
Definition: json.hpp:5831
std::uint64_t subtype_type
Definition: json.hpp:5828
bool operator==(const byte_container_with_subtype &rhs) const
Definition: json.hpp:5859
BinaryType container_type
Definition: json.hpp:5827
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:5853
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:5841
constexpr subtype_type subtype() const noexcept
return the binary subtype
Definition: json.hpp:5880
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
Definition: json.hpp:5846
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
Definition: json.hpp:5887
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
Definition: json.hpp:5836
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
Definition: json.hpp:5872
void clear_subtype() noexcept
clears the binary subtype
Definition: json.hpp:5894
deserialization of CBOR, MessagePack, and UBJSON values
Definition: json.hpp:9146
binary_reader(const binary_reader &)=delete
binary_reader(binary_reader &&)=default
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
Definition: json.hpp:9162
binary_reader & operator=(const binary_reader &)=delete
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
Definition: json.hpp:9183
binary_reader & operator=(binary_reader &&)=default
serialization to CBOR and MessagePack values
Definition: json.hpp:14992
void write_bson(const BasicJsonType &j)
Definition: json.hpp:15012
static constexpr CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:16747
static CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:16754
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
Definition: json.hpp:15003
static constexpr CharType to_char_type(InputCharType x) noexcept
Definition: json.hpp:16776
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false)
Definition: json.hpp:15691
void write_msgpack(const BasicJsonType &j)
Definition: json.hpp:15365
void write_cbor(const BasicJsonType &j)
Definition: json.hpp:15041
general exception of the basic_json class
Definition: json.hpp:4306
const int id
the id of the exception
Definition: json.hpp:4315
static std::string diagnostics(std::nullptr_t)
Definition: json.hpp:4326
static std::string name(const std::string &ename, int id_)
Definition: json.hpp:4321
const char * what() const noexcept override
returns the explanatory string
Definition: json.hpp:4309
static std::string diagnostics(const BasicJsonType *leaf_element)
Definition: json.hpp:4332
exception indicating errors with iterators
Definition: json.hpp:4457
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4460
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
Definition: json.hpp:12837
iter_impl operator+(difference_type i) const
add to iterator
Definition: json.hpp:13411
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition: json.hpp:12974
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition: json.hpp:13356
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition: json.hpp:12964
bool operator<(const iter_impl &other) const
comparison: smaller
Definition: json.hpp:13303
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition: json.hpp:13338
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition: json.hpp:13402
iter_impl & operator--()
pre-decrement (–it)
Definition: json.hpp:13217
const object_t::key_type & key() const
return the key of an object iterator
Definition: json.hpp:13511
bool operator==(const IterImpl &other) const
comparison: equal
Definition: json.hpp:13258
iter_impl operator++(int) &
post-increment (it++)
Definition: json.hpp:13155
iter_impl & operator+=(difference_type i)
add to iterator
Definition: json.hpp:13365
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:13473
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
Definition: json.hpp:12867
pointer operator->() const
dereference the iterator
Definition: json.hpp:13113
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:13536
difference_type operator-(const iter_impl &other) const
return difference
Definition: json.hpp:13444
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17.
Definition: json.hpp:12862
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition: json.hpp:13422
reference value() const
return the value of an iterator
Definition: json.hpp:13527
bool operator>(const iter_impl &other) const
comparison: greater than
Definition: json.hpp:13347
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
Definition: json.hpp:12871
iter_impl & operator++()
pre-increment (++it)
Definition: json.hpp:13166
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
Definition: json.hpp:12865
reference operator*() const
return a reference to the value pointed to by the iterator
Definition: json.hpp:13069
iter_impl operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:13433
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
Definition: json.hpp:12949
bool operator!=(const IterImpl &other) const
comparison: not equal
Definition: json.hpp:13294
iter_impl operator--(int) &
post-decrement (it–)
Definition: json.hpp:13206
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
Definition: json.hpp:12876
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
Definition: json.hpp:12939
void set_end() noexcept
set the iterator past the last value
Definition: json.hpp:13030
Definition: json.hpp:5120
iteration_proxy_value operator++(int) &
Definition: json.hpp:5176
iteration_proxy_value(iteration_proxy_value const &)=default
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
Definition: json.hpp:5185
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
Definition: json.hpp:5191
std::ptrdiff_t difference_type
Definition: json.hpp:5122
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
Definition: json.hpp:5143
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
Definition: json.hpp:5168
iteration_proxy_value()=default
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
Definition: json.hpp:5127
IteratorType::reference value() const
return value of the iterator
Definition: json.hpp:5233
const string_type & key() const
return key of the iterator
Definition: json.hpp:5197
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
std::input_iterator_tag iterator_category
Definition: json.hpp:5126
proxy class for the items() function
Definition: json.hpp:5241
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
Definition: json.hpp:5266
iteration_proxy(iteration_proxy const &)=default
iteration_proxy()=default
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
Definition: json.hpp:5260
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
Definition: json.hpp:5250
iteration_proxy & operator=(iteration_proxy const &)=default
Definition: json.hpp:14733
json_ref(json_ref &&) noexcept=default
json_ref(const value_type &value)
Definition: json.hpp:14741
json_ref(value_type &&value)
Definition: json.hpp:14737
value_type const & operator*() const
Definition: json.hpp:14772
value_type const * operator->() const
Definition: json.hpp:14777
json_ref(std::initializer_list< json_ref > init)
Definition: json.hpp:14745
json_ref(Args &&... args)
Definition: json.hpp:14752
value_type moved_or_copied() const
Definition: json.hpp:14763
BasicJsonType value_type
Definition: json.hpp:14735
a template for a reverse iterator class
Definition: json.hpp:13590
json_reverse_iterator operator++(int) &
post-increment (it++)
Definition: json.hpp:13606
json_reverse_iterator operator--(int) &
post-decrement (it–)
Definition: json.hpp:13618
json_reverse_iterator & operator++()
pre-increment (++it)
Definition: json.hpp:13612
std::ptrdiff_t difference_type
Definition: json.hpp:13592
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition: json.hpp:13630
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:13654
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
Definition: json.hpp:13660
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition: json.hpp:13648
typename Base::reference reference
the reference type for the pointed-to element
Definition: json.hpp:13596
reference value() const
return the value of an iterator
Definition: json.hpp:13667
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition: json.hpp:13603
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition: json.hpp:13624
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
Definition: json.hpp:13594
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:13642
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition: json.hpp:13599
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition: json.hpp:13636
Definition: json.hpp:7226
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:7229
bool end_object()
Definition: json.hpp:7279
bool start_object(std::size_t=static_cast< std::size_t >(-1))
Definition: json.hpp:7269
bool binary(binary_t &)
Definition: json.hpp:7264
bool number_integer(number_integer_t)
Definition: json.hpp:7244
bool start_array(std::size_t=static_cast< std::size_t >(-1))
Definition: json.hpp:7284
bool boolean(bool)
Definition: json.hpp:7239
bool null()
Definition: json.hpp:7234
bool end_array()
Definition: json.hpp:7289
bool number_unsigned(number_unsigned_t)
Definition: json.hpp:7249
bool string(string_t &)
Definition: json.hpp:7259
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:7232
bool number_float(number_float_t, const string_t &)
Definition: json.hpp:7254
bool parse_error(std::size_t, const std::string &, const detail::exception &)
Definition: json.hpp:7294
bool key(string_t &)
Definition: json.hpp:7274
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:7228
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:7230
typename BasicJsonType::string_t string_t
Definition: json.hpp:7231
Definition: json.hpp:6919
bool boolean(bool val)
Definition: json.hpp:6950
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:7107
typename BasicJsonType::string_t string_t
Definition: json.hpp:6924
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:6968
constexpr bool is_errored() const
Definition: json.hpp:7119
bool string(string_t &val)
Definition: json.hpp:6974
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6922
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6925
bool start_object(std::size_t len)
Definition: json.hpp:6986
bool start_array(std::size_t len)
Definition: json.hpp:7057
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6921
bool end_array()
Definition: json.hpp:7074
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
bool key(string_t &val)
Definition: json.hpp:7004
bool end_object()
Definition: json.hpp:7021
~json_sax_dom_callback_parser()=default
typename BasicJsonType::parse_event_t parse_event_t
Definition: json.hpp:6927
typename BasicJsonType::parser_callback_t parser_callback_t
Definition: json.hpp:6926
bool null()
Definition: json.hpp:6944
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:6962
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
Definition: json.hpp:6929
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6923
bool number_integer(number_integer_t val)
Definition: json.hpp:6956
bool binary(binary_t &val)
Definition: json.hpp:6980
SAX implementation to create a JSON value from SAX events.
Definition: json.hpp:6736
json_sax_dom_parser(const json_sax_dom_parser &)=delete
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool string(string_t &val)
Definition: json.hpp:6790
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
Definition: json.hpp:6749
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:6857
bool null()
Definition: json.hpp:6760
~json_sax_dom_parser()=default
typename BasicJsonType::string_t string_t
Definition: json.hpp:6741
bool start_object(std::size_t len)
Definition: json.hpp:6802
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6739
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:6778
bool number_integer(number_integer_t val)
Definition: json.hpp:6772
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6738
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool binary(binary_t &val)
Definition: json.hpp:6796
json_sax_dom_parser(json_sax_dom_parser &&)=default
bool boolean(bool val)
Definition: json.hpp:6766
bool end_array()
Definition: json.hpp:6846
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:6784
bool end_object()
Definition: json.hpp:6824
constexpr bool is_errored() const
Definition: json.hpp:6869
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6742
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6740
bool start_array(std::size_t len)
Definition: json.hpp:6834
bool key(string_t &val)
Definition: json.hpp:6814
Definition: json.hpp:7341
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
Definition: json.hpp:7368
token_type
token types for the parser
Definition: json.hpp:7345
lexical analysis
Definition: json.hpp:7418
bool skip_bom()
skip the UTF-8 byte order mark
Definition: json.hpp:8792
void skip_whitespace()
Definition: json.hpp:8806
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
Definition: json.hpp:7429
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
Definition: json.hpp:8779
std::string get_token_string() const
return the last read token (for errors only).
Definition: json.hpp:8754
constexpr number_integer_t get_number_integer() const noexcept
return integer value
Definition: json.hpp:8718
constexpr position_t get_position() const noexcept
return position of last read token
Definition: json.hpp:8746
token_type scan()
Definition: json.hpp:8814
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
Definition: json.hpp:8724
typename lexer_base< BasicJsonType >::token_type token_type
Definition: json.hpp:7427
lexer & operator=(lexer &&)=default
lexer(const lexer &)=delete
lexer & operator=(lexer &)=delete
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
Definition: json.hpp:8736
constexpr number_float_t get_number_float() const noexcept
return floating-point value
Definition: json.hpp:8730
exception indicating other library errors
Definition: json.hpp:4509
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4512
exception indicating access out of the defined range
Definition: json.hpp:4492
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4495
Definition: json.hpp:14950
output_adapter(StringType &s)
Definition: json.hpp:14961
output_adapter(std::basic_ostream< CharType > &s)
Definition: json.hpp:14957
output_adapter(std::vector< CharType, AllocatorType > &vec)
Definition: json.hpp:14953
output adapter for output streams
Definition: json.hpp:14902
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
Definition: json.hpp:14904
void write_character(CharType c) override
Definition: json.hpp:14908
output adapter for basic_string
Definition: json.hpp:14927
void write_character(CharType c) override
Definition: json.hpp:14933
output_string_adapter(StringType &s) noexcept
Definition: json.hpp:14929
output adapter for byte vectors
Definition: json.hpp:14877
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
Definition: json.hpp:14879
void write_character(CharType c) override
Definition: json.hpp:14883
exception indicating a parse error
Definition: json.hpp:4404
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
Definition: json.hpp:4416
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4424
const std::size_t byte
byte index of the parse error
Definition: json.hpp:4441
syntax analysis
Definition: json.hpp:12162
parser(InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
a parser reading from an input adapter
Definition: json.hpp:12172
void parse(const bool strict, BasicJsonType &result)
public parser interface
Definition: json.hpp:12194
bool accept(const bool strict=true)
public accept interface
Definition: json.hpp:12254
bool sax_parse(SAX *sax, const bool strict=true)
Definition: json.hpp:12262
Definition: json.hpp:12654
primitive_iterator_t & operator++() noexcept
Definition: json.hpp:12716
primitive_iterator_t & operator-=(difference_type n) noexcept
Definition: json.hpp:12748
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
Definition: json.hpp:12683
primitive_iterator_t & operator--() noexcept
Definition: json.hpp:12729
void set_end() noexcept
set iterator to a defined past the end
Definition: json.hpp:12677
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:12699
constexpr bool is_end() const noexcept
return whether the iterator is at end
Definition: json.hpp:12689
primitive_iterator_t operator++(int) &noexcept
Definition: json.hpp:12722
primitive_iterator_t & operator+=(difference_type n) noexcept
Definition: json.hpp:12742
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:12694
constexpr difference_type get_value() const noexcept
Definition: json.hpp:12665
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:12711
primitive_iterator_t operator+(difference_type n) noexcept
Definition: json.hpp:12704
void set_begin() noexcept
set iterator to a defined beginning
Definition: json.hpp:12671
primitive_iterator_t operator--(int) &noexcept
Definition: json.hpp:12735
Definition: json.hpp:17973
std::array< char, 512 > string_buffer
string buffer
Definition: json.hpp:18897
std::uint8_t state
Definition: json.hpp:18315
std::size_t bytes_after_last_accept
Definition: json.hpp:18319
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
Definition: json.hpp:17988
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
Definition: json.hpp:18313
std::size_t undumped_chars
Definition: json.hpp:18320
const char thousands_sep
the locale's thousand separator character
Definition: json.hpp:18892
const char decimal_point
the locale's decimal point character
Definition: json.hpp:18894
serializer & operator=(const serializer &)=delete
const error_handler_t error_handler
error_handler how to react on decoding errors
Definition: json.hpp:18905
string_t indent_string
the indentation string
Definition: json.hpp:18902
const std::lconv * loc
the locale
Definition: json.hpp:18890
serializer & operator=(serializer &&)=delete
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
Definition: json.hpp:18887
const char indent_char
the indentation character
Definition: json.hpp:18900
std::size_t bytes
Definition: json.hpp:18316
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
Definition: json.hpp:18028
serializer(const serializer &)=delete
serializer(serializer &&)=delete
exception indicating executing a member function with a wrong type
Definition: json.hpp:4475
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4478
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
Definition: json.hpp:13754
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
Definition: json.hpp:13849
typename string_t_helper< RefStringType >::type string_t
Definition: json.hpp:13776
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
Definition: json.hpp:13856
json_pointer(const string_t &s="")
create JSON pointer
Definition: json.hpp:13780
bool empty() const noexcept
return whether pointer points to the root document
Definition: json.hpp:13915
friend bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointers for equality
Definition: json.hpp:14649
void pop_back()
remove last reference token
Definition: json.hpp:13877
string_t to_string() const
return a string representation of the JSON pointer
Definition: json.hpp:13786
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
Definition: json.hpp:13834
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:13908
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
Definition: json.hpp:13816
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
Definition: json.hpp:13841
json_pointer parent_pointer() const
returns the parent of this JSON pointer
Definition: json.hpp:13863
friend bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointers for inequality
Definition: json.hpp:14674
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
Definition: json.hpp:13826
friend class json_pointer
Definition: json.hpp:13760
const string_t & back() const
return last reference token
Definition: json.hpp:13889
friend std::ostream & operator<<(std::ostream &o, const json_pointer &ptr)
write string representation of the JSON pointer to stream
Definition: json.hpp:13807
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:13901
friend bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointer for less-than
Definition: json.hpp:14699
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
Definition: json.hpp:5314
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
Definition: json.hpp:2588
#define JSON_HEDLEY_CONST
Definition: json.hpp:1818
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
Definition: json.hpp:1102
#define JSON_INLINE_VARIABLE
Definition: json.hpp:2491
#define JSON_HEDLEY_WARN_UNUSED_RESULT
Definition: json.hpp:1448
#define JSON_PRIVATE_UNLESS_TESTED
Definition: json.hpp:2551
#define NLOHMANN_JSON_VERSION_PATCH
Definition: json.hpp:70
#define JSON_HEDLEY_LIKELY(expr)
Definition: json.hpp:1713
#define JSON_HEDLEY_NON_NULL(...)
Definition: json.hpp:1606
#define JSON_INTERNAL_CATCH(exception)
Definition: json.hpp:2518
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition: json.hpp:24378
#define JSON_HEDLEY_RETURNS_NON_NULL
Definition: json.hpp:2047
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:14649
#define JSON_CATCH(exception)
Definition: json.hpp:2517
#define JSON_ASSERT(x)
Definition: json.hpp:2544
#define JSON_THROW(exception)
Definition: json.hpp:2515
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
Definition: json.hpp:77
#define NLOHMANN_JSON_VERSION_MAJOR
Definition: json.hpp:68
#define NLOHMANN_BASIC_JSON_TPL
Definition: json.hpp:2598
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1714
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
Definition: json.hpp:12052
#define JSON_TRY
Definition: json.hpp:2516
#define NLOHMANN_JSON_NAMESPACE_END
Definition: json.hpp:144
#define JSON_NO_UNIQUE_ADDRESS
Definition: json.hpp:2497
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:14674
#define NLOHMANN_JSON_VERSION_MINOR
Definition: json.hpp:69
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
Definition: json.hpp:2773
#define NLOHMANN_JSON_NAMESPACE_BEGIN
Definition: json.hpp:134
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
Definition: json.hpp:12049
#define JSON_HEDLEY_DIAGNOSTIC_POP
Definition: json.hpp:1103
#define JSON_EXPLICIT
Definition: json.hpp:2810
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
Definition: json.hpp:1396
#define JSON_HEDLEY_PURE
Definition: json.hpp:1787
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:14699
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
Definition: json.hpp:22800
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
Definition: json.hpp:17312
cached_power get_cached_power_for_binary_exponent(int e)
Definition: json.hpp:17148
Target reinterpret_bits(const Source source)
Definition: json.hpp:16868
boundaries compute_boundaries(FloatType value)
Definition: json.hpp:17009
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
Definition: json.hpp:17366
constexpr int kAlpha
Definition: json.hpp:17131
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
Definition: json.hpp:17648
constexpr int kGamma
Definition: json.hpp:17132
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
Definition: json.hpp:17407
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
Definition: json.hpp:17748
JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
Definition: json.hpp:17800
constexpr bool is_transparent()
Definition: json.hpp:4127
constexpr bool is_c_string()
Definition: json.hpp:4099
detail namespace with internal helper functions
Definition: json.hpp:249
input_format_t
the supported input formats
Definition: json.hpp:6108
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
Definition: json.hpp:5714
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition: json.hpp:309
typename make_void< Ts... >::type void_t
Definition: json.hpp:255
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
Definition: json.hpp:9007
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
Definition: json.hpp:14872
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
Definition: json.hpp:4208
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
Definition: json.hpp:9015
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
Definition: json.hpp:12153
OutStringType concat(Args &&... args)
Definition: json.hpp:4282
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
Definition: json.hpp:4217
decltype(T::to_json(std::declval< Args >()...)) to_json_function
Definition: json.hpp:3504
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
Definition: json.hpp:3210
decltype(std::declval< T >().template get< U >()) get_template_function
Definition: json.hpp:3510
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
Definition: json.hpp:3948
JSON_HEDLEY_RETURNS_NON_NULL char * to_chars(char *first, const char *last, FloatType value)
generates a decimal representation of the floating-point number value in [first, last).
Definition: json.hpp:17885
typename T::pointer pointer_t
Definition: json.hpp:3495
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
Definition: json.hpp:4202
parse_event_t
Definition: json.hpp:12136
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
Definition: json.hpp:4211
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
Definition: json.hpp:4944
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
Definition: json.hpp:4755
typename utility_internal::Gen< T, N >::type make_integer_sequence
Definition: json.hpp:3171
typename T::value_type value_type_t
Definition: json.hpp:3489
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
Definition: json.hpp:313
T conditional_static_cast(U value)
Definition: json.hpp:3982
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
Definition: json.hpp:4223
typename std::enable_if< B, T >::type enable_if_t
Definition: json.hpp:3083
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
Definition: json.hpp:8976
typename T::mapped_type mapped_type_t
Definition: json.hpp:3483
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
Definition: json.hpp:2958
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
Definition: json.hpp:8984
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
Definition: json.hpp:3676
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:5276
cbor_tag_handler_t
how to treat CBOR tags
Definition: json.hpp:9118
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
typename detected_or< Default, Op, Args... >::type detected_or_t
Definition: json.hpp:306
decltype(T::from_json(std::declval< Args >()...)) from_json_function
Definition: json.hpp:3507
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
Definition: json.hpp:6513
make_integer_sequence< size_t, N > make_index_sequence
Definition: json.hpp:3179
std::integral_constant< bool, Value > bool_constant
Definition: json.hpp:4089
void concat_into(OutStringType &)
Definition: json.hpp:4198
typename T::key_type key_type_t
Definition: json.hpp:3486
constexpr bool value_in_range_of(T val)
Definition: json.hpp:4083
value_t
the JSON type enumeration
Definition: json.hpp:2860
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
Definition: json.hpp:4005
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
Definition: json.hpp:8992
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
Definition: json.hpp:4838
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition: json.hpp:300
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: json.hpp:5956
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
Definition: json.hpp:4214
typename T::iterator_category iterator_category_t
Definition: json.hpp:3501
std::size_t combine(std::size_t seed, std::size_t h) noexcept
Definition: json.hpp:5938
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition: json.hpp:2889
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition: json.hpp:6456
decltype(std::declval< T & >().end_array()) end_array_function_t
Definition: json.hpp:9010
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
Definition: json.hpp:3960
error_handler_t
how to treat decoding errors
Definition: json.hpp:17965
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
std::size_t concat_length()
Definition: json.hpp:4167
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
Definition: json.hpp:3679
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
Definition: json.hpp:4598
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
Definition: json.hpp:3583
void to_json(BasicJsonType &j, T b) noexcept
Definition: json.hpp:5576
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition: json.hpp:4612
decltype(std::declval< T & >().null()) null_function_t
Definition: json.hpp:8968
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition: json.hpp:3187
typename T::difference_type difference_type_t
Definition: json.hpp:3492
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition: json.hpp:3069
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
Definition: json.hpp:4938
typename T::is_transparent detect_is_transparent
Definition: json.hpp:3918
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
Definition: json.hpp:8988
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
Definition: json.hpp:13708
typename T::reference reference_t
Definition: json.hpp:3498
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
Definition: json.hpp:8972
decltype(std::declval< T & >().end_object()) end_object_function_t
Definition: json.hpp:9003
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
Definition: json.hpp:3951
typename T::key_compare detect_key_compare
Definition: json.hpp:3567
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
Definition: json.hpp:8996
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
Definition: json.hpp:4220
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
Definition: json.hpp:8980
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition: json.hpp:294
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition: json.hpp:2978
void int_to_string(string_type &target, std::size_t value)
Definition: json.hpp:5113
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
Definition: json.hpp:4010
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
Definition: json.hpp:3932
is_detected< string_can_append, StringType, Arg > detect_string_can_append
Definition: json.hpp:4205
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
Definition: json.hpp:9000
Definition: json.hpp:24384
Definition: json.hpp:5297
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.hpp:24451
namespace for Niels Lohmann
Definition: json.hpp:5767
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
Definition: json.hpp:5791
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
Definition: json.hpp:5781
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
Definition: json.hpp:5771
Definition: json.hpp:3575
typename BasicJsonType::object_t object_t
Definition: json.hpp:3576
typename BasicJsonType::default_object_comparator_t object_comparator_t
Definition: json.hpp:3577
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
Definition: json.hpp:3579
Definition: json.hpp:3590
std::true_type value_t
Definition: json.hpp:289
Op< Args... > type
Definition: json.hpp:290
std::false_type value_t
Definition: json.hpp:282
Default type
Definition: json.hpp:283
Definition: json.hpp:16996
diyfp w
Definition: json.hpp:16997
diyfp minus
Definition: json.hpp:16998
diyfp plus
Definition: json.hpp:16999
Definition: json.hpp:17135
std::uint64_t f
Definition: json.hpp:17136
int e
Definition: json.hpp:17137
int k
Definition: json.hpp:17138
Definition: json.hpp:16878
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
Definition: json.hpp:16902
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
Definition: json.hpp:16984
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
Definition: json.hpp:16967
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
Definition: json.hpp:16890
constexpr diyfp(std::uint64_t f_, int e_) noexcept
Definition: json.hpp:16884
static constexpr int kPrecision
Definition: json.hpp:16879
std::uint64_t f
Definition: json.hpp:16881
int e
Definition: json.hpp:16882
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
Definition: json.hpp:5501
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
Definition: json.hpp:5476
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
Definition: json.hpp:5466
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
Definition: json.hpp:5488
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
Definition: json.hpp:5517
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
Definition: json.hpp:5405
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
Definition: json.hpp:5414
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
Definition: json.hpp:5359
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
Definition: json.hpp:5427
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
Definition: json.hpp:5453
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
Definition: json.hpp:5440
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
Definition: json.hpp:5536
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
Definition: json.hpp:5557
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
Definition: json.hpp:5546
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
Definition: json.hpp:5381
static void construct(BasicJsonType &j, const CompatibleStringType &str)
Definition: json.hpp:5392
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
Definition: json.hpp:5372
Definition: json.hpp:5353
Definition: json.hpp:5033
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
Definition: json.hpp:5035
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3529
Definition: json.hpp:3514
Definition: json.hpp:3570
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3544
Definition: json.hpp:3539
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3559
Definition: json.hpp:3554
Definition: json.hpp:4549
Definition: json.hpp:3111
T value_type
Definition: json.hpp:3112
static constexpr std::size_t size() noexcept
Definition: json.hpp:3113
an iterator value
Definition: json.hpp:12770
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:12774
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:12776
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:12772
Definition: json.hpp:3463
Definition: json.hpp:3450
Definition: json.hpp:4114
Definition: json.hpp:3909
Definition: json.hpp:3773
Definition: json.hpp:3792
std::numeric_limits< RealIntegerType > RealLimits
Definition: json.hpp:3850
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
Definition: json.hpp:3851
Definition: json.hpp:3840
Definition: json.hpp:3863
typename BasicJsonType::object_t object_t
Definition: json.hpp:3701
Definition: json.hpp:3693
Definition: json.hpp:3713
Definition: json.hpp:3750
static constexpr auto value
Definition: json.hpp:3751
Definition: json.hpp:3866
Definition: json.hpp:3879
Definition: json.hpp:3686
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value) &&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
Definition: json.hpp:3822
Definition: json.hpp:3795
Definition: json.hpp:3836
typename BasicJsonType::object_t object_t
Definition: json.hpp:3725
Definition: json.hpp:3717
Definition: json.hpp:3746
Definition: json.hpp:3757
ConstructibleStringType laundered_type
Definition: json.hpp:3762
static constexpr auto value
Definition: json.hpp:3765
Definition: json.hpp:3882
Definition: json.hpp:3623
Definition: json.hpp:3603
Definition: json.hpp:3522
static constexpr bool value
Definition: json.hpp:3523
Definition: json.hpp:6432
typename std::iterator_traits< T >::value_type value_type
Definition: json.hpp:6433
Definition: json.hpp:3639
Definition: json.hpp:3888
Definition: json.hpp:3473
Definition: json.hpp:3970
char x[2]
Definition: json.hpp:3971
Definition: json.hpp:3966
static one test(decltype(&C::capacity))
@ value
Definition: json.hpp:3977
char one
Definition: json.hpp:3967
Definition: json.hpp:3658
static constexpr bool value
Definition: json.hpp:3672
Definition: json.hpp:9050
Definition: json.hpp:9019
static constexpr bool value
Definition: json.hpp:9032
Definition: json.hpp:3899
Definition: json.hpp:4136
T value_type
Definition: json.hpp:3291
T * pointer
Definition: json.hpp:3293
ptrdiff_t difference_type
Definition: json.hpp:3292
T & reference
Definition: json.hpp:3294
std::random_access_iterator_tag iterator_category
Definition: json.hpp:3290
Definition: json.hpp:3278
typename It::iterator_category iterator_category
Definition: json.hpp:3271
typename It::difference_type difference_type
Definition: json.hpp:3267
typename It::value_type value_type
Definition: json.hpp:3268
typename It::reference reference
Definition: json.hpp:3270
typename It::pointer pointer
Definition: json.hpp:3269
Definition: json.hpp:3259
Default base class of the basic_json class.
Definition: json.hpp:13701
void type
Definition: json.hpp:253
Definition: json.hpp:3597
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete
abstract output adapter interface
Definition: json.hpp:14858
output_adapter_protocol(const output_adapter_protocol &)=default
virtual ~output_adapter_protocol()=default
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
output_adapter_protocol()=default
virtual void write_characters(const CharType *s, std::size_t length)=0
struct to capture the start position of the current token
Definition: json.hpp:3024
std::size_t chars_read_current_line
the number of characters read in the current line
Definition: json.hpp:3028
std::size_t lines_read
the number of lines read
Definition: json.hpp:3030
std::size_t chars_read_total
the total number of characters read
Definition: json.hpp:3026
Definition: json.hpp:3194
Definition: json.hpp:3200
static JSON_INLINE_VARIABLE constexpr T value
Definition: json.hpp:3201
Definition: json.hpp:5734
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
Definition: json.hpp:5736
Definition: json.hpp:3131
Definition: json.hpp:3150
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
Definition: json.hpp:3152
static constexpr bool test(T val)
Definition: json.hpp:4067
static constexpr bool test(T)
Definition: json.hpp:4076
Definition: json.hpp:4062
static constexpr bool test(T val)
Definition: json.hpp:4020
static constexpr bool test(T val)
Definition: json.hpp:4040
static constexpr bool test(T val)
Definition: json.hpp:4030
static constexpr bool test(T val)
Definition: json.hpp:4051
Definition: json.hpp:4015
SAX interface.
Definition: json.hpp:6605
virtual bool binary(binary_t &val)=0
a binary value was read
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
virtual bool key(string_t &val)=0
an object key was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6606
typename BasicJsonType::string_t string_t
Definition: json.hpp:6609
virtual bool end_array()=0
the end of an array was read
json_sax(const json_sax &)=default
virtual bool boolean(bool val)=0
a boolean value was read
virtual bool end_object()=0
the end of an object was read
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6608
virtual bool null()=0
a null value was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6607
json_sax(json_sax &&) noexcept=default
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6610
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
a minimal map-like container that preserves insertion order
Definition: json.hpp:18947
std::vector< std::pair< const Key, T >, Allocator > Container
Definition: json.hpp:18950
std::pair< iterator, bool > insert(value_type &&value)
Definition: json.hpp:19241
typename Container::value_type value_type
Definition: json.hpp:18954
std::equal_to< Key > key_compare
Definition: json.hpp:18958
iterator erase(iterator pos)
Definition: json.hpp:19119
T mapped_type
Definition: json.hpp:18949
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
Definition: json.hpp:18964
T & operator[](KeyType &&key)
Definition: json.hpp:19006
typename Container::iterator iterator
Definition: json.hpp:18951
const T & at(KeyType &&key) const
Definition: json.hpp:19066
T & at(KeyType &&key)
Definition: json.hpp:19038
const T & operator[](KeyType &&key) const
Definition: json.hpp:19018
iterator find(const key_type &key)
Definition: json.hpp:19203
iterator erase(iterator first, iterator last)
Definition: json.hpp:19124
const T & at(const key_type &key) const
Definition: json.hpp:19051
const_iterator find(const key_type &key) const
Definition: json.hpp:19229
T & operator[](const key_type &key)
Definition: json.hpp:18999
size_type erase(KeyType &&key)
Definition: json.hpp:19100
typename Container::size_type size_type
Definition: json.hpp:18953
ordered_map() noexcept(noexcept(Container()))
Definition: json.hpp:18963
void insert(InputIt first, InputIt last)
Definition: json.hpp:19264
size_type count(const key_type &key) const
Definition: json.hpp:19177
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
Definition: json.hpp:18986
size_type erase(const key_type &key)
Definition: json.hpp:19079
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
Definition: json.hpp:18968
std::pair< iterator, bool > insert(const value_type &value)
Definition: json.hpp:19246
size_type count(KeyType &&key) const
Definition: json.hpp:19191
Key key_type
Definition: json.hpp:18948
ordered_map(It first, It last, const Allocator &alloc=Allocator())
Definition: json.hpp:18966
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
Definition: json.hpp:19261
const T & operator[](const key_type &key) const
Definition: json.hpp:19011
iterator find(KeyType &&key)
Definition: json.hpp:19217
T & at(const key_type &key)
Definition: json.hpp:19023
typename Container::const_iterator const_iterator
Definition: json.hpp:18952
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
Definition: json.hpp:18971
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
Definition: json.hpp:24420
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition: json.hpp:24434